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

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 Comments

Interesting issue. I cannot duplicate. When I run the code on my desktop in R2023b, I get the same plot as what was generated by running the code in your post.
I it keeps happening after restarting, I suggest contacting support: https://www.mathworks.com/support/contact_us.html
Diid you run it in live editor?...it runs fine if you just run it from the regular editor..
I just copied the code form this posting into a new live script editor tab and ran it, and it showed the issue....but perhaps this is just happening for me....
Yes, I used the live editor. I just tested it again, and I get the desired result. What operating system are you using?
The only plotting functions you have in your code are plot and yline. Let's make sure you're calling the versions of those functions you think you're calling. What does this code show when run inside your Live Script and in the Command Window?
which -all plot
built-in (/MATLAB/toolbox/matlab/graph2d/plot) /MATLAB/toolbox/matlab/graphics/math/@digraph/plot.m % digraph method /MATLAB/toolbox/matlab/graphics/math/@graph/plot.m % graph method /MATLAB/toolbox/matlab/timeseries/@timeseries/plot.m % timeseries method /MATLAB/toolbox/matlab/graphics/math/@polyshape/plot.m % polyshape method /MATLAB/toolbox/matlab/graphics/math/@alphaShape/plot.m % alphaShape method /MATLAB/toolbox/signal/signal/@dspdata/@abstractfreqresp/plot.m % dspdata.psd method /MATLAB/toolbox/matlab/bigdata/@tall/plot.m % tall method /MATLAB/toolbox/bioinfo/bioinfo/@phytree/plot.m % phytree method /MATLAB/toolbox/bioinfo/microarray/@HeatMap/plot.m % HeatMap method /MATLAB/toolbox/bioinfo/microarray/@clustergram/plot.m % clustergram method /MATLAB/toolbox/curvefit/curvefit/@cfit/plot.m % cfit method /MATLAB/toolbox/curvefit/curvefit/@sfit/plot.m % sfit method /MATLAB/toolbox/econ/econ/@conjugateblm/plot.m % conjugateblm method /MATLAB/toolbox/econ/econ/@diffuseblm/plot.m % diffuseblm method /MATLAB/toolbox/econ/econ/@mixconjugateblm/plot.m % mixconjugateblm method /MATLAB/toolbox/econ/econ/@lassoblm/plot.m % lassoblm method /MATLAB/toolbox/econ/econ/@mixsemiconjugateblm/plot.m % mixsemiconjugateblm method /MATLAB/toolbox/econ/econ/@empiricalblm/plot.m % empiricalblm method /MATLAB/toolbox/econ/econ/@blm/plot.m % blm method /MATLAB/toolbox/econ/econ/@customblm/plot.m % customblm method /MATLAB/toolbox/econ/econ/@semiconjugateblm/plot.m % semiconjugateblm method /MATLAB/toolbox/ident/ident/@iddata/plot.m % iddata method /MATLAB/toolbox/ident/nlident/@idnlarx/plot.m % idnlarx method /MATLAB/toolbox/ident/nlident/@idnlhw/plot.m % idnlhw method /MATLAB/toolbox/mpc/mpc/@mpc/plot.m % mpc method /MATLAB/toolbox/risk/risk/@varbacktest/plot.m % varbacktest method /MATLAB/toolbox/robust/rctobsolete/robust/@frd/plot.m % frd method /MATLAB/toolbox/robust/robust/@umargin/plot.m % umargin method /MATLAB/toolbox/shared/channel/rfprop/@propagationData/plot.m % propagationData method /MATLAB/toolbox/shared/drivingscenario/@drivingScenario/plot.m % drivingScenario method /MATLAB/toolbox/signal/signal/@dspdata/plot.m % dspdata method /MATLAB/toolbox/stats/bayesoptim/@BayesianOptimization/plot.m % BayesianOptimization method /MATLAB/toolbox/stats/classreg/@LinearModel/plot.m % LinearModel method /MATLAB/toolbox/wavelet/wavelet/@dtree/plot.m % dtree method /MATLAB/toolbox/wavelet/wavelet/@wdectree/plot.m % wdectree method /MATLAB/toolbox/wavelet/wavelet/@ntree/plot.m % ntree method
which -all yline
/MATLAB/toolbox/matlab/specgraph/yline.m
Since neither of the first two plots in your question have a horizontal line, I'm suspicious of yline.
yeah, but yline is not use by the first plot where the issue firsts shows up:
plot(timetot,amp,'-k')
>> which -all plot
built-in (C:\Program Files\MATLAB\R2023b\toolbox\matlab\graph2d\plot)
C:\Program Files\MATLAB\R2023b\toolbox\matlab\graphics\math\@digraph\plot.m % digraph method
C:\Program Files\MATLAB\R2023b\toolbox\matlab\graphics\math\@graph\plot.m % graph method
C:\Program Files\MATLAB\R2023b\toolbox\matlab\graphics\math\@polyshape\plot.m % polyshape method
C:\Program Files\MATLAB\R2023b\toolbox\matlab\graphics\math\@alphaShape\plot.m % alphaShape method
C:\Program Files\MATLAB\R2023b\toolbox\matlab\bigdata\@tall\plot.m % tall method
C:\Program Files\MATLAB\R2023b\toolbox\matlab\timeseries\@timeseries\plot.m % timeseries method
C:\Program Files\MATLAB\R2023b\toolbox\signal\signal\@dspdata\plot.m % dspdata method
C:\Program Files\MATLAB\R2023b\toolbox\stats\bayesoptim\@BayesianOptimization\plot.m % BayesianOptimization method
C:\Program Files\MATLAB\R2023b\toolbox\stats\classreg\@LinearModel\plot.m % LinearModel method
>>which -all yline
C:\Program Files\MATLAB\R2023b\toolbox\matlab\specgraph\yline.m
I'm running
OS Name Microsoft Windows 10 Business
Version 10.0.19045 Build 19045
I'd again suggest contacting support. Whatever is happening, this is something they'd like to know about anyway.
I did, I took your advice from earlier and contacted them.
thank you.
jorge

Sign in to comment.

Answers (0)

Categories

Products

Release

R2023b

Asked:

on 8 Nov 2023

Commented:

on 10 Nov 2023

Community Treasure Hunt

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

Start Hunting!