Why Unrecognized function or variable 'set_point'?

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

Is that a To Workspace block? Or are you logging the signal?
I suggest for debugging you use
out = sim('simulation_of_dc_motor_control');
whos
fieldnames(out)
i want to try find angular position dc motor control using state feedback
What output did you get when you use the debugging steps that I suggested?

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

답변 (1개)

Fangjun Jiang
Fangjun Jiang 2022년 6월 30일

1 개 추천

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.

카테고리

도움말 센터File Exchange에서 Data Logging에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2022년 6월 29일

답변:

2022년 6월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by