Good day everyone,
excuse me but i am very new to matlab..
I am generating a time series, to perform a fatigue test.

 채택된 답변

Daniel M
Daniel M 2019년 10월 28일

0 개 추천

You can follow this example:
lb = 5; % lower bound, ymin
ub = 10; % upper bound
N = 1000; % num samples
vals = rand(1,N).*(ub-lb) + lb;

추가 답변 (1개)

Akira Agata
Akira Agata 2019년 10월 28일

0 개 추천

How about the following?
N = [1000 , 500 , 2000 , 300 , 700 , 1000]; % No of samples
NI = length(N);
y_min = 10 + (60-10)*rand(1,NI); % Random between 10 and 60
y_max = zeros(size(y_min));
for kk = 1:NI % Create y_max which is random num between max(y_min(kk), 15) and 75
if y_min(kk) < 15
y_max(kk) = 15 + (75-15)*rand;
else
y_max(kk) = y_min(kk) + (75-y_min(kk))*rand;
end
end
Y = zeros(1,sum(N));
T = 1:sum(N);
Ncs = [0, cumsum(N)];
for kk = 1:NI
Y(Ncs(kk)+1:Ncs(kk+1)) = y_min(kk) + (y_max(kk)-y_min(kk))*rand(1,N(kk));
end
figure
plot(T,Y,'k')
grid on
box on

댓글 수: 1

Akira Agata
Akira Agata 2019년 10월 29일
To generate random integer number, please try randi function.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

질문:

2019년 10월 28일

편집:

2020년 7월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by