Function or variable 'rscale' not recognised.

22 visualizzazioni (ultimi 30 giorni)
ys
ys il 12 Giu 2023
Risposto: Mr. Pavl M. il 5 Dic 2024
A = [ 0 1 0
980 0 -2.8
0 0 -100 ];
B = [ 0
0
100 ];
C = [ 1 0 0 ];
poles = eig(A)
poles = 3×1
31.3050 -31.3050 -100.0000
t = 0:0.01:2;
u = zeros(size(t));
x0 = [0.01 0 0];
sys = ss(A,B,C,0);
[y,t,x] = lsim(sys,u,t,x0);
plot(t,y)
title('Open-Loop Response to Non-Zero Initial Condition')
xlabel('Time (sec)')
ylabel('Ball Position (m)')
p1 = -10 + 10i;
p2 = -10 - 10i;
p3 = -50;
K = place(A,B,[p1 p2 p3]);
sys_cl = ss(A-B*K,B,C,0);
lsim(sys_cl,u,t,x0);
xlabel('Time (sec)')
ylabel('Ball Position (m)')
p1 = -20 + 20i;
p2 = -20 - 20i;
p3 = -100;
K = place(A,B,[p1 p2 p3]);
sys_cl = ss(A-B*K,B,C,0);
lsim(sys_cl,u,t,x0); xlabel('Time (sec)')
ylabel('Ball Position (m)')
t = 0:0.01:2;
u = 0.001*ones(size(t));
sys_cl = ss(A-B*K,B,C,0);
lsim(sys_cl,u,t); xlabel('Time (sec)')
ylabel('Ball Position (m)')
axis([0 2 -4E-6 0])
Nbar = rscale(sys,K)
Unrecognized function or variable 'rscale'.
Function or variable 'rscale' is not recognised by matlab. I get an error like this.
However, the url above has this code description. How can I use it?

Risposte (2)

Rik
Rik il 12 Giu 2023
As it says right on that page:
"Note that this function is not standard in MATLAB. You will need to download it here, rscale.m, and save it to your current workspace."

Mr. Pavl M.
Mr. Pavl M. il 5 Dic 2024
clc
clear all
close all
A = [ 0 1 0
980 0 -2.8
0 0 -100 ];
B = [ 0
0
100 ];
C = [ 1 0 0 ];
D = [0];
poles = eig(A)
poles = 3×1
31.3050 -31.3050 -100.0000
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
ts = 0.001;
sys = ss(A,B,C,D,ts);
G = ss2tf(sys.A,sys.B,sys.C,sys.D)
G = 1×4
0 0 0 -280
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
p1 = -20 + 20i;
p2 = -20 - 20i;
p3 = -100;
K = place(sys.A,sys.B,exp(ts*[p1 p2 p3]))
K = 1×3
10.0301 -3.5098 -1.0286
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
%In place of separate function invokation, faster
s4 = size(sys.A,1);
Z = [zeros([1,s4]) 1];
N = (1\([sys.A,sys.B;sys.C,sys.D]))*Z';
Nx = N(1:s4);
Nu = N(1+s4);
Nbar=Nu + K*Nx
Nbar = -102.8648
%
opts = hinfsynOptions('Display','on');
W1 = makeweight(100,[1],0.25,ts);
W3 = makeweight(0.25,[1],100,ts);
%W2 = makeweight(0.01,[0.1],1,ts);
figure
bodemag(W1,[],W3)
P = augw(sys,[],[],W3)
P = A = x1 x2 x3 x4 x1 0.9018 4 0 0 x2 0 0 1 0 x3 0 980 0 -2.8 x4 0 0 0 -100 B = u1 u2 x1 0 0 x2 0 0 x3 0 0 x4 0 100 C = x1 x2 x3 x4 y1 -2.329 95.1 0 0 y2 0 -1 0 0 D = u1 u2 y1 0 0 y2 1 0 Input groups: Name Channels U1 1 U2 2 Output groups: Name Channels Y1 1 Y2 2 Sample time: 0.001 seconds Discrete-time state-space model.
%ncont = 1; % one control signal, u
%nmeas = 2; % 1 measurement signals
%[K,CL,gamma] = hinfsyn(P,ncont,nmeas,opts)
%contact me more if want this to study more interactively and to complete.

Categorie

Scopri di più su Signal Processing Toolbox in Help Center e File Exchange

Tag

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by