我有一个.m脚本,我一直在使用 Windows任务计划程序运行,通常成功,大约一年每15分钟一次(选项:-automation -minimize -r remotedata -logfile logfile.txt;quit
)。< / p>
当我在Matlab中手动运行代码时,一切都按预期运行。
但是,当它作为自动脚本运行时,它有两个我无法解决的问题,似乎表明代码没有以相同的方式执行。
首先,我有以下条件:
~isempty(remoteData.Time(setdiff(1:end,ni)))
这是一种可怕的语法,我知道,但是当我手动运行脚本时工作得很好。但是,当它自动运行时,会出现错误:
Error using setdiff (line 80) Not enough input arguments.
我将其更正为~isempty(remoteData.Time(setdiff(1:height(remoteData),ni)))
但这让我很好奇。
第二,我有一个webread
函数,其中包含许多查询(见下文),当我打开它并点击&#34;运行&#34;时,它会正常执行,当作为自动化运行时,dateutc
查询将被忽略。这个有点令人费解。任何人都可以提出一个可能无法注册的原因,或者我如何修复它?调试很困难,因为它在我手动运行时按预期工作。
WUurl = 'http://weatherstation.wunderground.com/weatherstation/updateweatherstation.php';
WUID = '***';
WUpwd = '***';
WUdateutc = datestr(datenum(webData.Time(WDNewest-newTimes+i))+7/24,'yyyy-mm-dd HH:MM:SS');
WUwindspeedmph = num2str(webData.WndSpd(WDNewest-newTimes+i)*0.62);
WUwinddir = num2str(webData.WndDir(WDNewest-newTimes+i));
WUtempf = num2str(webData.AirTmp(WDNewest-newTimes+i)*1.8+32);
WUrainin = num2str(webData.Rain(WDNewest-newTimes+i)/25.4*4);
WUdailyrainin = num2str(sum(webData.Rain(WDMidnight:WDNewest-newTimes+i))/25.4);
WUbaromin = num2str(webData.BarPress(WDNewest-newTimes+i)*.0295);
WUhumidity = num2str(webData.RelHum(WDNewest-newTimes+i));
gamma = log(webData.RelHum(WDNewest-newTimes+i)/100)+ ...
(17.67*webData.AirTmp(WDNewest-newTimes+i))/ ...
(243.5+webData.AirTmp(WDNewest-newTimes+i));
WUdewptf = num2str((243.5*gamma)/(17.67-gamma)*1.8+32); % Magnus formula estimation
WUsolarradiation = num2str(webData.NetRad_Wm2(WDNewest-newTimes+i));
WUsoiltempf = num2str(nanmean(webData{WDNewest,20:3:77})*1.8+32);
WUsoilmoisture = num2str(nanmean(webData{WDNewest,18:3:75}));
options = weboptions('Timeout',newTimes);
WU_debugging = webread(WUurl,...
'ID',WUID,...
'PASSWORD',WUpwd,...
'dateutc',WUdateutc,...
'windspeedmph',WUwindspeedmph,...
'winddir',WUwinddir,...
'tempf',WUtempf,...
'rainin',WUrainin,...
'dailyrainin',WUdailyrainin,...
'baromin',WUbaromin,...
'humidity',WUhumidity,...
'dewptf',WUdewptf,...
'solarradiation',WUsolarradiation,...
'soiltempf',WUsoiltempf,...
'soilmoisture',WUsoilmoisture,...
'action','updateraw',...
options);