2D graph help
显示 更早的评论
Hello,
I am getting an error. When I tried to plot these P1 and P2 function on the same graph. Can anyone help me for the code that I need to use? My code file is attached and it is working fine. I just need to add a plot.
3 个评论
Image Analyst
2016-1-23
Working fine? Don't you want to make P1 and P2 arrays rather than just a single value? A plot with just two points on it is not very interesting. Do you want them to be values at an index of "i"? Or "k" since most people don't want to use i (the imaginary variable) as a variable.
Yellow Canary
2016-1-24
Image Analyst
2016-1-24
Yes, but nothing happens. There is no call to plot() in the code. Please post the entire code, not a snippet that doesn't show what you want to show.
回答(1 个)
Jeevan Joishi
2016-1-27
Based on your sample code and the description of your question above, I understand that you would like to plot the values of variables P1 and P2 that is gathered for the complete iteration of the loop.
At the present instance, the values of the variable P1 and P2 are overridden in each iteration of the loop and hence the final values in P1 and P2 are simply single values as opposed to an array. There are two ways of going about it -
1) It appears that the table is infact storing the values of P1 and P2 after each iteration. Here P1 is stored in the third column and P2 is recorded in the fourth column of the table. These values can be used to plot as follows -
>> plot(table(:,3))
>> hold on
>> plot(table(:,4))
2) Another possible approach is to change all declarations of P1 and P2 to P1(i) and P2(i) in the loop, excluding the declaration where P1 and P2 are concatenated into P, and plot these values after the script executes. The following command should plot the complete values of P1 and P2.
>> plot(P1)
>> hold on
>> plot(P2)
Drop a comment if I have misunderstood your question or up-vote if it works for you.
类别
在 帮助中心 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!