Filter löschen
Filter löschen

Data plots incorrectly when in Live Script, but shows up correctly when the same incorrect plot is popped out --why?

12 Ansichten (letzte 30 Tage)
I have a live script (.mlx file) that plots 2 cycles of a pulse train that has frequency and duty cycle as inputs. For some frequencies it is almost as if some of the interim points are not plotted, and instead only straight line between the end points are. However, the "intermediate" points are all there in the arrays I'm ploting, and in fact, when I pop the plot out, it the plot displays correctly. So, it appears to be a rendering issue within Live Script....
This is what I see in Live Script:
and this is what I get when I pop the plot out: (the correct waveform):
Here is my script to see if anyone can recreate what I´m seeing in Live Editor vs. "Matlab". It renders correctly on here as shown below (note: the plot below is full plot while above I only showed the first waveform plotted on the axis.)
R = 10; % these are sliders in the .mlx file [0:1:20]
D = 0.5; % [.1:.1:1]
f = 129000; % [1000:1000:10e6]
A = 5;
C = 0.047e-6;
tau = (R*C)
tau = 4.7000e-07
%tau_disp = ['RC Tau = ', num2eng(tau)];
%disp(tau_disp)
T= 1./f;
ton = T.*D;
toff = T.*(1-D);
t1= linspace(0,ton,100);
t2 = linspace(0,toff,100);
hi = repmat(A,1,size(t1,2));
lo = repmat(0,1,size(t2,2));
time = [t1 t1(end)+t2];
amp = [hi lo];
% plot 2 cycles
timetot= [time time(end)+time];
amp =[amp amp];
% debug
%fig1=figure();
%plot(timetot,amp,'-*k') % added * to see the point on the plot...
%hold on;
fig=figure();
hold on;
xlabel('time (secs)')
ylabel('amplitude (volts)')
title([{'Resulting Ave Value and';'Ripple as Function of DC and Freq'}])
plot(timetot,amp,'-k') % this plot is different in Live Script vs. Matlab at certain frequencies....
Amplitude = D*A;
x1 = A*(exp(-D.*T/tau)-1).*exp(T.*(D-1)/tau)./(-1+exp(-T/tau));
x2 = (exp(-D.*T/tau)-1)*A./(-1+exp(-T/tau));
plot(0,x1,'*k',t1,x1+(A-x1)*(1-exp(-t1/tau)),'-r')
plot(ton,x2,'*k',ton+t2,x2*exp(-t2/tau),'-r')
plot(T,x1,'*k',T+t1,x1+(A-x1)*(1-exp(-t1/tau)),'-r')
plot(T+ton,x2,'*k',T+ton+t2,x2*exp(-t2/tau),'-r')
plot(2*T,x1,'*k')
yline(Amplitude,'--b')
Ripple = (x2 - x1)./(A*D);
rip = sprintf('Ripple = %2.2f %%',Ripple*100);
disp(rip)
Ripple = 199.90 %
Ave = sprintf('Average Amplitude = %2.2f volts', Amplitude);
disp(Ave)
Average Amplitude = 2.50 volts
  7 Kommentare
Cris LaPierre
Cris LaPierre am 10 Nov. 2023
I'd again suggest contacting support. Whatever is happening, this is something they'd like to know about anyway.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by