Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Simple question how do I adjust the for loop to go through the rows of the excel matrix one by one. Milesdriven adds the columns 2:11 of the first row, i want the calculation to be done for the next 54 rows as well.

1 回表示 (過去 30 日間)
Khalid Tewfik
Khalid Tewfik 2016 年 12 月 4 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
filename = 'project3data.xlsx';
num = xlsread('project3data.xlsx');
for i = 1:55
milesdriven = sum(num(2,2:11))
end

回答 (1 件)

Tamir Suliman
Tamir Suliman 2016 年 12 月 5 日
filename = 'project3data.xlsx';
num = xlsread('project3data.xlsx');
for i = 1:55
for j =2:11
milesdriven = sum(num(i,j))
end
end
  1 件のコメント
Walter Roberson
Walter Roberson 2016 年 12 月 5 日
That will not work, that overwrites the answer each time.

Community Treasure Hunt

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

Start Hunting!

Translated by