Multivariable matrix m.file coding error.

1 次查看(过去 30 天)
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.....

回答(1 个)

Sara Xie
Sara Xie 2017-8-3
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.

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by