MATLAB Answers

plotting in a loop with a function

10 ビュー (過去 30 日間)
Benjamin
Benjamin 2019 年 3 月 5 日
コメント済み: Benjamin 2019 年 3 月 5 日
I have the following code:
for x = 1:0.01:1.5
z = g(x,rpf);
end
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?

採用された回答

Bob Thompson
Bob Thompson 2019 年 3 月 5 日
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);
end
plot(x,z)
  7 件のコメント
Benjamin
Benjamin 2019 年 3 月 5 日
I created a new question, maybe you could answer this question there.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by