我的任务是创建一个脚本,用于统计每年VEI >=3
的喷发量。然后在屏幕上显示有关VEI >=3
的火山名称和日期,并使用VEI >=3
保存年度喷发次数。
数据在excel文件中。加载文件后,这是我的脚本写的:
% read the data
[volcname,volcVEI,starteruptyear,starteruptmonth] = textread(inFile,'%s %f %f %f %*f %*f %*f %*f','headerlines',1,'delimiter',',');
%theVEI is an index for all the VEI >=3
theVEI = find(volcVEI >= 3)
theYear = starteruptyear(theVEI);
Yearvolc = unique(theYear);
startyear = min(Yearvolc);
endyear = max(Yearvolc);
for i = theVEI
%theVEI(year)
% Using the index value defined by i, I pluck out
screenprint = sprintf('The volcano %s, erupted on year %g, the %g month, with an intensity of VEI %g',volcname{i},starteruptyear(i),starteruptmonth(i),volcVEI(i));
disp(screenprint)
end
示例数据: