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

조회 수: 1(최근 30일)
Stephen Devlin 9 Mar 2018
편집: Jan 10 Mar 2018
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

로그인 to comment.

### 채택된 답변

Jan 9 Mar 2018
편집: Jan 9 Mar 2018
Maybe you mean:
Result = A(:, 1) + (0.05 - 0.1 * rand(size(A, 1), 1)) * A(:, 2)

#### 댓글 수: 3

Stephen Devlin 9 Mar 2018
This worked
Result = A(:, 2) + (0.05 - 0.1 * rand(size(A, 1), 1))
Thanks Jan
Jan 9 Mar 2018
@Stephen: Then I got it at least almost. :-)
Stephen Devlin 9 Mar 2018
:-) Its much appreciated Jan, I've used a few permutations of it now :-)

로그인 to comment.

### 추가 답변(0개)

이 질문에 답변하려면 로그인을(를) 수행하십시오.

Translated by