Code Error When Trying to Plot Scope to Matlab Graph
Ältere Kommentare anzeigen
What would cause the code "plot(ScopeData.time,ScopeData.signals.values,'or')" to have an error and how to fix it. This is my code:
x0 = -1;
A = -2;
B = 1;
C = 1;
D = 0;
t = linspace(0,10);
u = 2 +3*sin(3*t);
[y,~]=lsim(A,B,C,D,u,t,x0);
plot(t,y);
hold on
plot(ScopeData.time,ScopeData.signals.values,'or');
xlabel('time(s)');
ylabel('x(t)');
legend('lsim','simulink','Location','northwest');
This is my Simulink

4 Kommentare
Walter Roberson
am 14 Mär. 2020
Your code does not assign to ScopeData and does not call sim() so we have no expectation that something in the model might have assigned to ScopeData .
Kassandra Krinke
am 14 Mär. 2020
Aghamarsh Varanasi
am 17 Mär. 2020
Bearbeitet: Aghamarsh Varanasi
am 17 Mär. 2020
Hi Kassandra,
You are trying to plot ScopeData. ScopeData, which seems to be a structure, doesn't seem to be defined in the current scope. Could you please share your Simulink (.slx) file, pertaining to your model.
Kassandra Krinke
am 17 Mär. 2020
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu View and Analyze Simulation Results finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!