how to plot a graph from the results of for loop

1 view (last 30 days)
I want to plot a graph using X axis as p values and y axis as A values there is an error in the code...
any suggestions
clc;
close all;
clear all;
for p=[1.0 0.3 0.1 0.03 0.01 0.003 0.001];
p1=1;
f=30;
h=0.136;
t=65.5;
l=09;
lo=78;
R=224;
Reo=8500;
A = a2(p,p1,f,h,t,l,lo,R,Reo); %calling function from other matlab file
disp(p);
disp(A);
%plot (p,A);
end

Accepted Answer

Azzi Abdelmalek
Azzi Abdelmalek on 7 Nov 2013
Edited: Azzi Abdelmalek on 7 Nov 2013
plot (p,A,'o');
hold on
  4 Comments
Azzi Abdelmalek
Azzi Abdelmalek on 7 Nov 2013
For your case, I will do
clc;
close all;
A=[];
p=fliplr([1.0 0.3 0.1 0.03 0.01 0.003 0.001])
for k=1:numel(p)
p1=1;
f=30;
h=0.136;
t=65.5;
l=09;
lo=78;
R=224;
Reo=8500;
A(k) = a2(p(k),p1,f,h,t,l,lo,R,Reo);
disp(p(k));
disp(A(k));
end
plot(p,A)
set(gca,'xscale','log')

Sign in to comment.

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!