after run the below code this error generated (Sizes vector returned by MATLAB S-function 'new_two' in 'new_one/S-Function' must be a real vector consisting of integer value of length 7) please could any one support me in this issue
Show older comments
function [sys,x0,str,ts] = new_two(t,x,u,flag)
switch flag,
case 0,
[sys,x0,str,ts] = mdlInitializeSizes;
case 2,
sys = mdlUpdate(t,x,u);
case 3,
sys = mdlOutputs(t,x,u);
case 9,
sys = []; % do nothing
otherwise
DAStudio.error('Simulink:blocks:unhandledFlag', num2str(flag));
end
% mdlInitializeSizes
function [sys,x0,str,ts] = mdlInitializeSizes L = 1; N = 10; xn = linspace(0,L,N); tn = 0:1:9; h= xn'*tn; sizes = simsizes; sizes.NumContStates = 0; sizes.NumDiscStates = size(h); sizes.NumOutputs = size(h); sizes.NumInputs = size(tn); sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 1; sys = simsizes(sizes); x0 = zeros(size(h)); str = []; ts = [-1 0]; function sys = mdlUpdate(~,x,u) M = 1; L = 1; T = 10; N = 10; p = 0.1; xn = linspace(0,L,N); h = xn(2)-xn(1); k = (h/sqrt(T/p)); r = 0.8*((k^2*T)/(h^2*p)); v = (T*k^2)/(M*h); s = k^2/M; x(1) = (1-r)*x(2) + (r/2)*x(3) + x(4)+(k^2/(2*p))*u(1); x(5) = -x(6) + 2*(1-r)*x(7) + r*x(8) + x(9)+(k^2/p)*u(1); x(10) = (1/(2-v))*(x(11) + x(12) - x(13)+s*(u(2)+u(3))); sys(1) = x(1); sys(2) = x(2); sys(3) = x(3); sys(4) = x(4); sys(5) = x(5); sys(6) = x(6); sys(7) = x(7); sys(8) = x(8); sys(9) = x(9); sys(10)= x(10); sys(11)= x(11); sys(12)= x(12); sys(13)= x(13); function sys = mdlOutputs(~,x,~) sys = x;
Answers (0)
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!