homework help, my loglog wont plot a line
Show older comments
function [] =FFAplot(a,b,k)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
A=size(a);
B=size(b);
K=size(k);
p=(1/100);
T=100;
if A(1,1)==B(1,1)
if A(1,2)==B(1,2)
if (B(1,1)==K(1,1))||(B(1,2)==K(1,2))
j=0;
i=1:K(1,2);
Qi=zeros((A(1,1)),(A(1,2)));
while j==0
% Qi=((b(1,i))+(((a(1,i))/(k(1,i)))*(1-((-log(1-p)).^(k(1,i))))));
loglog((10),(10^6),'r')
hold on
plot(T,((b(1,i))+(((a(1,i))/(k(1,i)))*(1-((-log(1-p)).^(k(1,i)))))),'r')
%loglog(((b(1,i))+(((a(1,i))/(k(1,i)))*(1-((-log(1-p)).^(k(1,i)))))),T)
end
end
end
end
end
MY code wont plot anything it keeps just giving me the graph with the x and y values but no ploted line
Answers (1)
Star Strider
on 30 Jan 2018
It won’t because you didn’t tell it to. You told it to plot a point, and since the default behavoiur of plot is to connect two (or more) points with lines, it drew nothing.
If you want it to plot the point, plot a marker:
loglog((10),(10^6),'pr')
8 Comments
Faith Dominguez
on 30 Jan 2018
Walter Roberson
on 30 Jan 2018
Edited: Walter Roberson
on 30 Jan 2018
To plot a line, you need to pass a list of two or more points to one of the plotting functions.
... What you should be doing is storing the x and y coordinates that you are plotting at into a vector, and not plotting inside the loop. Plot the vectors after the loop.
I notice that your T is not changing, so your points would all be at x = 100. Is that what you wanted?
You are not changing j inside your loop, so your while j==0 is an infinite loop.
Star Strider
on 30 Jan 2018
It depends on what you want to plot.
Try this:
figure
loglog([1 10], [1 100000], 'b') % Plot Arbitrary Function
hold on
loglog(xlim, [1; 1]*[10 10^6],'-r') % Plot Parallel Red Lines
hold off
axis([xlim 1 1E+7]) % Set ‘axis’ Limits To Be Cure To Show Lines
Faith Dominguez
on 30 Jan 2018
Edited: Walter Roberson
on 30 Jan 2018
Walter Roberson
on 30 Jan 2018
I would suggest, though, that if you only have a single x value, that using a loglog plot does not make sense, that semilogy would make more sense.
Faith Dominguez
on 30 Jan 2018
Walter Roberson
on 30 Jan 2018
Ah.
With your T being constant you are only going to vertical lines.
Also when you use 'pr' you specify pentagram marker in red, but you would not get any line. You would need a line specification as well such as '-pr' to get lines. Which might fold back on themselves... I doubt you really want T (x coordinate) to be constant.
Star Strider
on 30 Jan 2018
Also, we never did resolve the problem of ‘K(1,2)’ being anything other than 1. If it is greater than 1, then ‘i’ is a vector. That is going to cause problems.
Categories
Find more on Annotations 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!