フィルターのクリア

Error: Index out of bounds

2 ビュー (過去 30 日間)
ANOSH PHIROZ AMARIA
ANOSH PHIROZ AMARIA 2018 年 9 月 11 日
コメント済み: madhan ravi 2018 年 9 月 11 日
I am running the following MATLAB code to get the weekly average of data in 52704 columns. The data is getting imported correctly, but the last column in the array of week_speed is not getting filled.
month=xlsread('2004.xlsx','11517-2004','B2: B52705'); % Extracting month
day=xlsread('2004.xlsx','11517-2004','C2: C52705');% Extracting day
seconds=xlsread('2004.xlsx','11517-2004','F2: F52705');%Extracting seconds
wind_speed=xlsread('2004.xlsx','11517-2004','H2: H52705');%Extractng wind speed
index=1;
week_speed=zeros(53,1);
average=zeros(53,1);
week=1;
incr=1;
index_avg=1;
count=zeros(53,1);
while incr<=52704
while week<55
while index<=1008
week_speed(week)=week_speed(week)+wind_speed(incr);
index=index+1;
incr=incr+1;
end
average(index_avg)=week_speed(week)./1008;
count(week)=week;
index_avg=index_avg+1;
index=1;
week=week+1;
end
end
plot(count,average);
Error Displayed:
Attempted to access wind_speed(52705);
index out of bounds because numel(wind_speed)=52704.
  8 件のコメント
ANOSH PHIROZ AMARIA
ANOSH PHIROZ AMARIA 2018 年 9 月 11 日
ohh so sorry I uploaded the wrong format. Just attached the right one
madhan ravi
madhan ravi 2018 年 9 月 11 日
first of all explain what you are doing inside the loop it's all scattered and hard to interpret

サインインしてコメントする。

採用された回答

madhan ravi
madhan ravi 2018 年 9 月 11 日
編集済み: madhan ravi 2018 年 9 月 11 日
[num,txt,raw]=xlsread('11517_2004.xlsx')
month=num(:,2)
day=num(:,3)
seconds=num(:,6)
wind_speed=num(:,8)
week_speed=zeros(numel(wind_speed),1);
for i=1:numel(wind_speed)
count(i)=i;
week_speed(i)=week_speed(i)+wind_speed(i);
average(i)=week_speed(i)./1008;
end
plot(count(1:54-1),average(1:54-1))
  1 件のコメント
madhan ravi
madhan ravi 2018 年 9 月 11 日
If it's not what you are looking for , let know.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by