Why Unrecognized function or variable 'set_point'?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
clear;clc;close all;
A = [0 1 0 ; 0 -10 7.5; 0 -0.15 2];
B = [0;0;2];
C = [1 0 0];
J = [-5 -5 -5];
K = acker(A,B,J);
KK = [0 K(2) K(3)];
k1 = K(1);
sim('simulation_of_dc_motor_control')
sp = set_point(:,1);
y = angular_position(:,1);
t = time_data(:,1);
figure
hold on;grid on;
plot(t,sp,t,y,'linewidth',2)
legend('set point','angular position')
stepinfo(y,t,sp(1))
sse = abs(sp(end)-y(end));
fprint('Steady State Error = %d \n',sse);
Hi, i've some trouble here, Here is my code, i got error "Unrecognized function or variable 'set_point'."
I make the simulink before and try to connect it to my script but i think it doesnt connect well.
Here is my block in simulink
How to solve it?
Thanks
3 commentaires
Walter Roberson
le 30 Juin 2022
What output did you get when you use the debugging steps that I suggested?
Réponses (1)
Fangjun Jiang
le 30 Juin 2022
The variable that you are looking for, "set_point",is in "out.set_point".
So, in your code, replace "set_point" with "out.set_point". You may also need to change it to "out.set_point.Time" and "out.set_point.Data" because the data is not saved as "Array" but "timeseries".
This is impacted by settings at "Configuration Parameters", "Data Import/Export". The "Single simulation output" must have been checked so the "To Workspace" block variable automatically becomes "out.set_point".
If you use sim(), you need to give it a return variable like, xyz=sim('ModelName'), then your variable is in "xyz.set_point".
The "Data Import/Export" has been changed quite a lot from old days. Play with it manually first to figure it out and then write your code.
0 commentaires
Voir également
Catégories
En savoir plus sur Variable Initialization dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!