plotting in a loop with a function

1 view (last 30 days)
I have the following code:
for x = 1:0.01:1.5
z = g(x,rpf);
but when I run this (assume my function is correct), I only get that z is equivalent to the last data point. How can I store x and z in a matrix and then plot them?

Accepted Answer

Bob Thompson
Bob Thompson on 5 Mar 2019
You need to index z with each loop.
count = 0;
for x = 1:0.01:1.5;
count = count + 1;
z(count) = g(x,rpf);
Benjamin on 5 Mar 2019
I created a new question, maybe you could answer this question there.

Sign in to comment.

More Answers (0)


Find more on Loops and Conditional Statements 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!