homework help, my loglog wont plot a line

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

답변 (1개)

Star Strider
Star Strider 2018년 1월 30일

0 개 추천

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

Faith Dominguez
Faith Dominguez 2018년 1월 30일
Is there a way to get loglog to plot a line? was looking it up on Matlab help but i cant find where it says the specifications to get a line. thank you
Walter Roberson
Walter Roberson 2018년 1월 30일
편집: Walter Roberson 2018년 1월 30일
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.
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
Faith Dominguez 2018년 1월 30일
편집: Walter Roberson 2018년 1월 30일
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))
Qi=zeros(1,K(1,2));
for i=1:K(1,2)
Qi(1,i)=((b(1,i))+(((a(1,i))/(k(1,i)))*(1-((-log(1-p)).^(k(1,i))))));
loglog((1),(10^6))
hold on
% plot(T,(b(1,i))+(((a(1,i))/(k(1,i)))*(1-((-log(1-p)).^(k(1,i))))),'pr')
loglog(T,Qi,'pr')
end
end
end
end
i've changed the code to this, i do want T to stay 100 , i think i have it storing the value into the array Qi
Walter Roberson
Walter Roberson 2018년 1월 30일
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
Faith Dominguez 2018년 1월 30일
The graph is supposed to look like this and the only way i could get x to look like that was using loglog
Walter Roberson
Walter Roberson 2018년 1월 30일
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
Star Strider 2018년 1월 30일
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.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

태그

질문:

2018년 1월 30일

댓글:

2018년 1월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by