Percentage change and plot

12 ビュー (過去 30 日間)
gorilla3
gorilla3 2017 年 10 月 18 日
回答済み: MAHANTH CHOUTA 2019 年 8 月 1 日
I ran my code multiple times, by assigning a different value to one of the variables (Pa) each time. The results are stored in a matrix of solutions (cbf) 285x7. The 1st column is the one with the baseline values.
I would now like to calculate the percentage change of each column with respect to the baseline column and plot it against Pa (%cfb change vs. Pa) Could you help me?
I presume I have to perform this calculation:
for n=1:7
percentage= ((cbf(:,n) - (cbf(:,1))) ./ cbf(:,1)).*100
end
But the plot of %change cbf against the Pa values that I manipulated appears only as a white canvas:
plot(percentage,Pa)

回答 (2 件)

KL
KL 2017 年 10 月 18 日
編集済み: KL 2017 年 10 月 18 日
You may want to store the output in a matrix though,
for n=1:size(cbf,2)-1
percentage(:,n)= ((cbf(:,n+1) - (cbf(:,1))) ./ cbf(:,1)).*100
end
or, you could just write without a loop,
percentage = ((cbf(:,2:end) - (cbf(:,1))) ./ cbf(:,1)).*100;

MAHANTH CHOUTA
MAHANTH CHOUTA 2019 年 8 月 1 日
use your graph to estimate the rate of change of profit of a company

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by