How to call n numbers from a Matrix

5 ビュー (過去 30 日間)
Rose Vogt
Rose Vogt 2020 年 11 月 26 日
回答済み: KSSV 2020 年 11 月 26 日
watlevel(n)=[1.8; 1.5; 1.2; 1.3; 1.4; 1.6; 1.7; 1.4; 1.1; 0.9; 0.2; 0.2]; %incoming water level
time(n)=[0; 3; 6; 9; 12; 15; 18; 21; 24; 27; 30; 45; 50]; %time
for i=1:100:3000
Time2=i;
Volume2=(watlevel(n).*B1.*B2.*(time(n+1)-time(n)))-(watlevel(1).*B1.*B2.*(time(n+1)-time(n)).*Time./(50.*60));
plot(Time2,Volume2,'ks','MarkerFaceColor','k');
xlabel('Time (sec)'); ylabel('Volume (m^3)');
end
I am trying to call the specific "n" values from my matrix to use in my for loop but I'm not sure how. Does anybody know how to make this work?

採用された回答

KSSV
KSSV 2020 年 11 月 26 日
watlevel=[1.8; 1.5; 1.2; 1.3; 1.4; 1.6; 1.7; 1.4; 1.1; 0.9; 0.2; 0.2]; %incoming water level
time=[0; 3; 6; 9; 12; 15; 18; 21; 24; 27; 30; 45; 50]; %time
Volume2 = zeros(1,length(time)-1) ;
for n=1:length(time)-1
Volume2(n)=(watlevel(n).*B1.*B2.*(time(n+1)-time(n)))-(watlevel(1).*B1.*B2.*(time(n+1)-time(n)).*Time./(50.*60));
end
plot(time(1:end-1),Volume2,'ks','MarkerFaceColor','k');
xlabel('Time (sec)'); ylabel('Volume (m^3)');

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeArray and Matrix Mathematics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by