error in zpk function

3 visualizzazioni (ultimi 30 giorni)
Andrea Gusmara
Andrea Gusmara il 21 Ago 2020
Risposto: Walter Roberson il 22 Ago 2020
Hi to everyone , i can't understand why matlab printthis error message ""
def = [
1 % IngressoTipo 1
1 % IngressoPar 2
1 % Uscita 3
0.0 % P_min 4
1 % P, P_cur 5
10 % P_max 6
1 % A, A_cur 7
1 % delta, delta_cur 8
4.5 % R1, R1_cur 9
5 % R2, R2_cur 10
0.0 % h10, h10_cur 11
0.0 % h2, h2_cur 12
];
%END PROJECT'S CODE
g = 9.81;
%BEGIN PROJECT'S CODE
h10 = def(11);
h20 = def(12);
A = def(7);
delta = def(8);
R1 = def(9);
R2 = def(10);
SetPoint= get(handles.SetPoint, 'Value');
Mu=str2num(str2mat(get(handles.Mu_string,'String')));
Nx=str2num(str2mat(get(handles.Nx_string,'String')));
Dx=str2num(str2mat(get(handles.Dx_string,'String')));
% END PROJECT'S CODE
% Calcolo costanti di tempo nel punto di eq.
F = [-delta*g/(A*R1) 0;
delta*g/(A*R1) -delta*g/(A*R2)];
Tau = TimeConstantLTI(F);
% valore di default in caso di fallimento calcolo
if isnan(Tau), Tau = 0.1; end
Tau = min(100, Tau); % sogliatura per evitare sim troppo lunghe
% Esporta tutte le variabili nel Workspace per permettere a Simulink
% di averne visibilità
vars = {'A', A; 'delta', delta; 'g', g; 'R1', R1; 'R2', R2; 'h10', h10; 'h20', h20;'SetPoint',SetPoint;'Mu',Mu;'Nx',Nx;'Dx',Dx};
for i = 1 : size(vars, 1)
name = vars(i, 1);
value = vars(i, 2);
assignin('base', name{1}, value{1});
end
% sistema
% Preparazione matrici F, G, H, J = 0
F = [-delta*g/(A*R1) 0;
delta*g/(A*R1) -delta*g/(A*R2)];
G = [1/A;
0];
H = [0 +1];
J = zeros(size(H, 1), size(G, 2));
sysProcesso = ss(F, G, H, J);
figure(1),bode(sysProcesso);
figure(2),nyquist(sysProcesso);
[NumP, DenP,GainP] = zpkdata(sysProcesso);
numAnello=[Nx cell2mat(NumP)];
denAnello=[Dx cell2mat(DenP)'];
guadagno=GainP*Mu;
fAnello=[mat2cell(numAnello,size(numAnello,1),size(numAnello,2)) ,mat2cell(denAnello,size(denAnello,1),size(denAnello,2)) , guadagno];
sysAnello=zpk(fAnello(1),fAnello(2),fAnello(3));
bode(sysAnello);
nyquist(sysAnello);
  2 Commenti
Walter Roberson
Walter Roberson il 21 Ago 2020
What is the error message? We do not have your graphics structure so we cannot test it out
Andrea Gusmara
Andrea Gusmara il 21 Ago 2020
The value of the "K" property must be a numeric array.

Accedi per commentare.

Risposte (2)

Andrea Gusmara
Andrea Gusmara il 21 Ago 2020
Mu=str2num(str2mat('[3]'));
Nx=str2num(str2mat('[10]'));
Dx=str2num(str2mat('[10]'));

Walter Roberson
Walter Roberson il 22 Ago 2020
fAnello=[mat2cell(numAnello,size(numAnello,1),size(numAnello,2)) ,mat2cell(denAnello,size(denAnello,1),size(denAnello,2)) , guadagno];
With all those mat2cell(), we can tell that fAnello is going to be a cell array.
sysAnello=zpk(fAnello(1),fAnello(2),fAnello(3));
That passes cells extracted from fAnello into zpk, as cells
"In the SISO case, Z and P are the vectors of real- or complex-valued zeros and poles, and K is the real- or complex-valued scalar gain:"
Not cells in that case.
For the MIMO case,
"Z and P are cell arrays of vectors with as many rows as outputs and as many columns as inputs, and K is a matrix with as many rows as outputs and as many columns as inputs. [...] K(i,j) specifies the (scalar) gain of the transfer function from input j to output i."
So Z and P can be cells for the MIMO case, but K must be numeric. You are passing in a cell for K.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by