How to plot the figure in the while loop ?

조회 수: 12 (최근 30일)
SU PIN-YAN
SU PIN-YAN 2021년 10월 4일
댓글: SU PIN-YAN 2021년 10월 5일
I want to plot the figure when the data is runned 10000 data ,and intergrate the four figure in one(about 8bit 10bit 12bit 14bit) .
when run 1 data , it's will be plot one figure but that's not my want . please help my code , thanks !
below is my code :
case 'JITTER & cs'
cs = linspace(2e-12 , 4e-12 , 10000)
J = linspace(0 , 5e-12 , 10000)
i =2; B_var=8;
while B_var < 15
Delta_var = (A^2)/(2^B_var);
QN = (Delta_var^2)/12;
JITTER = ((A^2)*(Win^2)*(J.*J))/2;
TN = k*T./cs;
Noise_both = JITTER+TN;
func = Psig./(QN+Noise_both);
SNR = 10*log10(func);
hold on;
figure;
plot(Noise_both,SNR);
title('SNR vs JITTER&cs')
B_var = 8+i;
end

답변 (1개)

the cyclist
the cyclist 2021년 10월 4일
Try putting the figure command and the hold on commands before the while loop (and put the figure command before the hold on).
If you paste your code here -- instead of an image of your code -- it would be easier to help, because we could run your code without needing to retype it all.
  댓글 수: 4
the cyclist
the cyclist 2021년 10월 4일
So, my suggestion was to change your code to this:
case 'JITTER & cs'
cs = linspace(2e-12 , 4e-12 , 10000)
J = linspace(0 , 5e-12 , 10000)
i =2; B_var=8;
figure
hold on
while B_var < 15
Delta_var = (A^2)/(2^B_var);
QN = (Delta_var^2)/12;
JITTER = ((A^2)*(Win^2)*(J.*J))/2;
TN = k*T./cs;
Noise_both = JITTER+TN;
func = Psig./(QN+Noise_both);
SNR = 10*log10(func);
plot(Noise_both,SNR);
title('SNR vs JITTER&cs')
B_var = 8+i;
end
but it is not possible to test this idea, because we don't have values for
A
Win
k
T
Psig
SU PIN-YAN
SU PIN-YAN 2021년 10월 5일
that's good ! the code can work and that's what I want to do , thanks !

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

카테고리

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

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by