フィルターのクリア

How can I change parameters during a plot?

2 ビュー (過去 30 日間)
Gabriel Oliviero
Gabriel Oliviero 2016 年 5 月 24 日
編集済み: Stephen23 2016 年 5 月 24 日
Hello,
I have 2D graph like:
x = []
hold on
for w= 20:100:20000
i= 0.5
x(end+1) = (i*sin(w))
end
hold off
w= 20:100:2020
plot(w,x)
In this case "i" is always 0.5, for all "w" values. I would like to know if there is anyway to plot a sigle plot graph, in wich the value of "i" varies depending on the band of "w".
  1 件のコメント
Stephen23
Stephen23 2016 年 5 月 24 日
編集済み: Stephen23 2016 年 5 月 24 日
Can you explain what you mean by "the band of "w"." ? What is a "band", can you show us an example of what such "band" values would be like?.
Note that how you are generating your data is very inefficient: using a loop and expanding the output array with each iteration is poor MATLAB code, it is much simpler and faster to write vectorized code instead, without using any loops:
>> w = 20:100:20000;
>> x = 0.5 * sin(w);
>> plot(w,x)
Note that your vector w increases in steps of 100: the function sin input is in radians (not degrees), so that step size makes your data essentially meaningless. A more typical step size would be 0.1 or so.

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by