Simulate single sine wave

조회 수: 2 (최근 30일)
MadjeKoe
MadjeKoe 2020년 11월 9일
댓글: Setsuna Yuuki. 2020년 11월 15일
Hi all, can someone please explain to me how I can similate this graph in matlab?

답변 (2개)

Sindar
Sindar 2020년 11월 9일
Without the noisy signal? See sin documentation.
With the signal (i.e. fitting to it), check out the answer to this question

Setsuna Yuuki.
Setsuna Yuuki. 2020년 11월 9일
time = linspace(0,5,200); %Sampling signal
signal = sin(2*pi*time); %sine wave
vectorx = [ones(1,length(time)/4) 3*ones(1,length(time)/4) ...
2*ones(1,length(time)/4) 4*ones(1,length(time)/4)];
errorSimulated = rand(1,length(vectorx)); %simulated error
yyaxis left; %name axis Y left
plot(time,signal); hold on; %plot sine wave
ylabel('Sinusoidal signal')
yyaxis right;%name axis Y right
scatter(vectorx,errorSimulated) %scatter of error
ylabel('Simulated error')
  댓글 수: 2
MadjeKoe
MadjeKoe 2020년 11월 15일
I get this graph now, did I do anything wrong? Is it btw possible that the y-axis reaches from -90 to 90, and the x-axis from -40 to 40?
Setsuna Yuuki.
Setsuna Yuuki. 2020년 11월 15일
yes, you only must add this lines
yyaxis left;
plot(time,signal); hold on;
ylabel('Sinusoidal signal')
ylim([-90 90]) %ylimit ---------- First line
yyaxis right;
scatter(vectorx,errorSimulated)
ylabel('Simulated error')
xlim([-40 40]) %xlimit ---------- Second line

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

카테고리

Help CenterFile Exchange에서 Whos에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by