2D plot array elements

I'm trying to plot elements from an array of solutions (value of percentage), against a changing parameter ABP. However I only get an empty figure.
valueofPercentage= [1 ... n] ABP=[1 ... n] , where n corresponds to 200 elements.
This is the code:
for s=1:1:200
ABP(P_a_b)=s;
end
for n=length(valueofCBF)
percentage= ((valueofCBF(:,1) - CBF_base)/ CBF_base)*100
valueofPercentage(n)=percentage;
end
for a=length(ABP)
figure(1)
hold on;
plot(ABP(a,:),valueofPercentage(a,:))
end
hold off;

6 件のコメント

Birdman
Birdman 2017 年 10 月 19 日
What is P_a_b? You did not define valueofCBF. You did not define CBF_base. This code is wrong. Correct them.
gorilla3
gorilla3 2017 年 10 月 19 日
P_a_b is a parameter that I use previously in the code, and I declared CBF_base as =9.003. But this is unnecessary information for this question. I need help with the syntax of the plot.
Rik
Rik 2017 年 10 月 19 日
編集済み: Rik 2017 年 10 月 19 日
You wrote for n=length(valueofCBF), usually that's an error and people mean for n= 1: length(valueofCBF). Same goes for the other for-loop.
There is a more fundamental problem: you are plotting a single value (ABP(a)) against a vector (valueofPercentage). This will result in an error.
Also, you should pre-allocate the vector valueofPercentage.
gorilla3
gorilla3 2017 年 10 月 19 日
Thanks, I changed it to n=1:length(valueCBF) and similarly for the next for loop.
Basically, in the workspace of the variables I obtain a 1x200 output for each: valuesofCBF and ABP. So I would like to plot element 1xn of ABP against 1xn of valueCBF
Rik
Rik 2017 年 10 月 19 日
Why don't you use plot(ABP,valueCBF) then? If you want to plot individual points one by one, make sure to include a hold on after the first plot and using a format for plot that shows points, like plot(ABP(a),valueCBF(a),'*')
gorilla3
gorilla3 2017 年 10 月 19 日
Thanks Rik!

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangePerformance and Memory についてさらに検索

質問済み:

2017 年 10 月 19 日

コメント済み:

2017 年 10 月 19 日

Community Treasure Hunt

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

Start Hunting!

Translated by