why i have this error 'Unrecognized function or variable 'idx_start'.

% Calcolo degli errori per ogni stato nell'intervallo di interesse
error_interval = error(idx_start:idx_end);
Unrecognized function or variable 'idx_start'.
error_state1 = x(idx_start:idx_end, 1) - xobs(idx_start:idx_end, 1);
error_state2 = x(idx_start:idx_end, 2) - xobs(idx_start:idx_end, 2);
error_state3 = x(idx_start:idx_end, 3) - xobs(idx_start:idx_end, 3);
error_state4 = x(idx_start:idx_end, 4) - xobs(idx_start:idx_end, 4);
error_state5 = x(idx_start:idx_end, 5) - xobs(idx_start:idx_end, 5);
error_state6 = x(idx_start:idx_end, 6) - xobs(idx_start:idx_end, 6);
% Grafico degli errori per ogni stato nell'intervallo di interesse
figure(4);
subplot(3, 2, 1);
plot(T(idx_start:idx_end), error_state1, 'b', 'LineWidth', 2);
xlabel('Tempo');
ylabel('Errore');
title('Errore Stato 1 (Intervallo [5-15] secondi)');
subplot(3, 2, 2);
plot(T(idx_start:idx_end), error_state2, 'b', 'LineWidth', 2);
xlabel('Tempo');
ylabel('Errore');
title('Errore Stato 2 (Intervallo [5-15] secondi)');
subplot(3, 2, 3);
plot(T(idx_start:idx_end), error_state3, 'b', 'LineWidth', 2);
xlabel('Tempo');
ylabel('Errore');
title('Errore Stato 3 (Intervallo [5-15] secondi)');
subplot(3, 2, 4);
plot(T(idx_start:idx_end), error_state4, 'b', 'LineWidth', 2);
xlabel('Tempo');
ylabel('Errore');
title('Errore Stato 4 (Intervallo [5-15] secondi)');
subplot(3, 2, 5);
plot(T(idx_start:idx_end), error_state5, 'b', 'LineWidth', 2);
xlabel('Tempo');
ylabel('Errore');
title('Errore Stato 5 (Intervallo [5-15] secondi)');
subplot(3, 2, 6);
plot(T(idx_start:idx_end), error_state6, 'b', 'LineWidth', 2);
xlabel('Tempo');
ylabel('Errore');
title('Errore Stato 6 (Intervallo [5-15] secondi)');

6 comentarios

Because you have not defined what idx_start (and idx_end) is.
What value should MATLAB use for the parameter?
thanks for helping me,
i also add my system but give me the same error:
clear all
global A B C L kp kd r s kI t ref integrale;
%syms r s
% Parametri del sistema
A = [5.389 -10 5.966 0 -5.966 -0.3333;
0.3333 0 -0.6667 0 -0.3333 -0.5774;
-6.158 20 -5.581 -10 5.581 -0.3333;
0.3333 -0 0.3333 0 0.6667 -0.5774;
0.3849 10 -0.1925 -10 0.1925 0.3333;
-0 0 -0 -0 0 -0];
B = [0.5774;0; 0.5774 ;0; -0.5774; 0 ];
C = [0 1 0 0 0 0 ];
D = 0;
C2 = eye(6);
sys = ss(A, B, C, D);
tf_sys = tf(sys);
Obs = obsv(A,C);
eig(A);
rank(Obs);
q = [-3 -3 -3 -3 -3 -3];
L = (acker(A', C', q))';
x0 = [1; 0; 0; 0; 0; 0];
x0obs = [0; 0; 0; 0; 0; 0];
z0 = [x0 x0obs];
Tspan = 15;
Dt = 0.001;
T = 0:Dt:Tspan;
u = sin(T/2);
Did you not read my comment?
You asked - why i have this error 'Unrecognized function or variable 'idx_start'.
I replied - Because you have not defined what idx_start (and idx_end) is. What value should MATLAB use for the parameter?
sorry i write also this : but now say that has too many arguments :
% Definizione dei tempi di interesse
t_start = 5; % Inizio dell'intervallo di interesse
t_end = 15; % Fine dell'intervallo di interesse
% Trovare gli indici corrispondenti agli istanti di tempo t_start e t_end
idx_start = find(t >= t_start, 1);
idx_end = find(t >= t_end, 1);
What is t?
Note that MATLAB is case-sensitive, so t is not equal to T.
Hi, can you provide the complete code? There is still no initialization of x, xobs, and t. Also, error_interval is not used anywhere post-initiated.

Iniciar sesión para comentar.

Respuestas (0)

Productos

Versión

R2023a

Preguntada:

el 12 de Oct. de 2023

Comentada:

el 2 de En. de 2024

Community Treasure Hunt

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

Start Hunting!