フィルターのクリア

How to randomly add variance in a graph plot

1 回表示 (過去 30 日間)
Krish Desai
Krish Desai 2015 年 9 月 28 日
コメント済み: Walter Roberson 2015 年 9 月 28 日
I'm graphing y=x, but I want to add a second plot of black stars where y is randomly + or - 0.25 I know the code to plot is
plot (x,y2, 'k*')
but how do I randomly add noise to create y2?

回答 (1 件)

Star Strider
Star Strider 2015 年 9 月 28 日
編集済み: Star Strider 2015 年 9 月 28 日
Experiment with the randn and rand functions to get the result you want.
  2 件のコメント
Krish Desai
Krish Desai 2015 年 9 月 28 日
But don't I need to do use the rand function each time then? So for x=1 I would have to use rand(2) and have 1 correspond with .25 and 2 with -.25. But then I would have to do this 10 more times. I want to make it more efficient. Would I be able to create a new vector and add this to y2?

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

カテゴリ

Help Center および File ExchangeGraph and Network Algorithms についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by