Multivariable matrix m.file coding error.

1 visualización (últimos 30 días)
Monika Rybczak
Monika Rybczak el 2 de Ag. de 2017
Comentada: Monika Rybczak el 22 de Ag. de 2017
I tired to write a very simple code but this is my first code so I have some problems, my matrix is KK and its size is [3x6], I have 6 inputs and 3 outputs:
function [sys, x0, str, ts] = inicjalizacja
mysizes = simsizes;
mysizes.NumContStates = 0;
mysizes.NumDiscStates = 0;
mysizes.NumInputs = 6;
mysizes.NumOutputs = 3;
mysizes.DirFeedthrough = 1;
mysizes.NumSampleTimes = 1;
sys = simsizes(mysizes)
x0 = []; str = [];
KK= [1.458e+3 0 -0.0004e+3 -0.7332e+3 0 0.0002e+3;
0.0001e+3 1.6243e+3 -0.0058e+3 0 -0.847e+3 0.0034e+3;
-0.0052e+3 -0.0016e+3 0.4215e+3 0.003e+3 0.001e+3 -0.2194e+3];
ts = [-1, 0]
function sys = Macierz_KK(t, x, u, KK)
sys = KK.*u;
end;
my problem is: Error: File: Macierz_KK.m Line: 19 Column: 5 The function "Macierz_KK" was closed with an 'end', but at least one other function definition was not. To avoid confusion when using nested functions, it is illegal to use both conventions in the same file.
When I tried to put another 'end' this doesn't work.....

Respuestas (1)

Sara Xie
Sara Xie el 3 de Ag. de 2017
Hi, looks like an 'end' is missing for function [sys, x0, str, ts] = inicjalizacja. Depends on how you want to create the function, if you are trying to create a local function, try add an 'end' after line 14, and if you want to create a nested function, try add an 'end' after line 19. To learn about local function and nested function, check this documentation
Note that if you want to call function Macierz_KK from another file, it has to be defined in a separate file.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by