フィルターのクリア

Hi , how can i plot of the sum of ode solutions using the sum function?

1 回表示 (過去 30 日間)
Aishah Malek
Aishah Malek 2018 年 7 月 18 日
回答済み: Aishah Malek 2018 年 7 月 22 日
Hi , I have plotted the following ode equations , and have plotted the sum of the solutions,how can i generalise the solution using the sum function?
clf
[tv,c] = ode45('beckerdorin',[0,3],[6,0,0,0]);
figure(2)
plot(tv,c(:,1),'r');hold on
plot(tv,c(:,2),'b');hold on
plot(tv,c(:,3),'y');hold on
plot(tv,c(:,4),'g');
title('Becker Doring Experiment')
figure(8)
plot(tv,c(:,1) +c(:,2) +c(:,3) +c(:,4),'m-');
I have tried the following, but i get a error.
figure(9)
plot(tv,sum(c(:,(1:1:4))),'m-')

回答 (2 件)

Aquatris
Aquatris 2018 年 7 月 18 日
編集済み: Aquatris 2018 年 7 月 18 日
You should use;
plot(tv,sum(c(:,1:4)'),'m-')
sum command sums each column, however, what you want is the sum of the rows. A simple transpose does the trick.

Aishah Malek
Aishah Malek 2018 年 7 月 22 日
Thankyou it now works

カテゴリ

Help Center および File ExchangeOrdinary Differential Equations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by