【发布时间】:2023-03-10 17:58:01
【问题描述】:
我正在从 url 读取数据,对其进行解析,然后尝试进一步格式化数据:
year = 2008;
month = 9;
day = 30;
raw = urlread(sprintf('http://www.wunderground.com/history/airport/KCVS/%i/%i/%i/DailyHistory.html?HideSpecis=0&theprefset=SHOWMETAR&theprefvalue=0&format=1',year,month,day));
data = textscan(raw,'%s %s %s %s %s %s %s %s %s %s %s %s','Delimiter',',','HeaderLines',2,'CollectOutput',true);
dir = data{1}(1:end-1,7);
wind = cellfun(@str2num,data{1}(1:end-1,8),'UniformOutput',false);
gust = cellfun(@str2num,data{1}(1:end-1,9),'UniformOutput',false);
wind{cellfun(@isempty,wind)} = 0;
gust{cellfun(@isempty,gust)} = 0;
现在wind{cellfun(@isempty,wind)} = 0; 可以工作,但gust{cellfun(@isempty,gust)} = 0; 不行,相反,我收到以下错误消息:???此赋值右侧的值太少,无法满足左侧的要求。 cellfun(@isempty,gust) 正确返回了一个逻辑数组。 gust{1} = 0 也可以。 为什么它适用于风而不适用于阵风?
【问题讨论】:
标签: matlab