I am not getting graphs for my matlab program. Can anyone help?
5 views (last 30 days)
Show older comments
I'm attaching my .m file. The graph should be drawn between L on x-axis and IL on y-axis, for L in between 0 and 100nH with a step size of 1nH. But, when i execute it, i am getting a blank graph. Please suggest any errors in my code.
2 Comments
Star Strider
on 1 Mar 2014
I can’t get your code to run, and until I can experiment with it, I can’t determine what is wrong with it.
The first problem is that drange is undefined.
Second, you’re running the plot in the for loop.
Third, you’re only asking it to plot one point (il) in each iteration of the loop.
Fourth, statements such as:
f=(2*10^9)
are not good programming practice. Use:
f=2E9; or f=2e9;
instead. You do that in a few other places as well.
Also, please describe what you are doing (why you wrote it) and you want it to do. We can never guess what you are thinking!
Accepted Answer
Walter Roberson
on 1 Mar 2014
It appears to me that your
plot(il);
is plotting individual points at height i1, each time at the same x = 1 location. When you plot(Y) then the x coordinates are assumed to be 1 : size(Y,1) (unless Y is row vector), and since your i1 is a single point the implication is that x will always be 1.
And each pass through, your plot() is triggering the erasure of the previous plot.
At the very least, add
hold on;
after the plot() call.
Are you sure you don't want to save all the i1 values and plot them at once afterwards? Such as by assigning to i1(p) inside the loop?
More Answers (0)
See Also
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!