How to make data random around a given point and within a particular range

1 回表示 (過去 30 日間)
Stephen Devlin
Stephen Devlin 2018 年 3 月 9 日
編集済み: Jan 2018 年 3 月 10 日
Hi, I am trying to write a table with some fake data and need it to compare to a checking vector(A(:,2)). In the checking vector each neighbouring field increments by a defined amount. I want the fake data to increment by an amount to bring the fake data field within say +/- 0.05 of whatever the checking vector is but to have this variance random. Is this possible?
A(:,1)=(1:5)%this is just an index
A(:,2)=[0;84.66716;169.33432;254.00148;338.66864;]%the check vector

採用された回答

Jan
Jan 2018 年 3 月 9 日
編集済み: Jan 2018 年 3 月 9 日
Maybe you mean:
Result = A(:, 1) + (0.05 - 0.1 * rand(size(A, 1), 1)) * A(:, 2)
  3 件のコメント
Jan
Jan 2018 年 3 月 9 日
編集済み: Jan 2018 年 3 月 10 日
@Stephen: Then I got it at least almost. :-)
Stephen Devlin
Stephen Devlin 2018 年 3 月 9 日
:-) Its much appreciated Jan, I've used a few permutations of it now :-)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by