From: Jonathan on
Hi,

I have a similar problem. I have the following function file:

function [A,B,C,D,K,x0] = DMCLinearModel(theta,T,varargin)
% theta(1), theta(2), theta(3), theta(4), theta(5), theta(6), theta(7), theta(8)
A = [-1/theta(1)*theta(3),1/theta(1)*(theta(6)*varargin(2)-theta(4)),0,0;
1/theta(2)*(theta(5)*varargin(1)-theta(3)),-1/theta(2)*theta(4),0,0;
-1/theta(1)/varargin(4)^2*(varargin(2)*varargin(8)-theta(3)*varargin(4)*varargin(6)-theta(4)*varargin(5)*varargin(7)-varargin(6)*(varargin(8)-theta(6)*varargin(2)*varargin(9)-theta(3)*varargin(4)+(theta(6)*varargin(2)-theta(4))*varargin(5))-theta(2)*varargin(5)*theta(8)*(varargin(3)-varargin(9))*(varargin(2)-varargin(7))-varargin(7)*(varargin(8)-theta(5)*varargin(1)*varargin(9)+(theta(5)*varargin(1)-theta(3))*varargin(4)-theta(4)*varargin(5)))-1/theta(1)/varargin(4)*varargin(7)*(theta(5)*varargin(1)-theta(3)),1/theta(1)/varargin(4)*(-varargin(6)*(theta(6)*varargin(2)-theta(4))-theta(2)*theta(8)*(varargin(3)-varargin(9))*(varargin(2)-varargin(7))),1/theta(1)/varargin(4)*(-varargin(8)+theta(6)*varargin(2)*varargin(9)-(theta(6)*varargin(2)-theta(4))*varargin(5)),1/theta(1)/varargin(4)*(theta(2)*varargin(5)*theta(8)*(varargin(3)-varargin(9))-varargin(8)+theta(5)*varargin(1)*varargin(9)-(theta(5)*varargin(1)-theta(3))*varargin(4));
-1/theta(2)/varargin(5)*varargin(7)*(theta(5)*varargin(1)-theta(3)),-1/theta(2)/varargin(5)^2*(varargin(2)*varargin(8)-theta(3)*varargin(4)*varargin(6)-theta(4)*varargin(5)*varargin(7)-theta(1)*theta(7)*(varargin(9)-varargin(3))*(varargin(2)-varargin(6))-varargin(6)*(varargin(8)-theta(6)*varargin(2)*varargin(9)-theta(3)*varargin(4)+(theta(6)*varargin(2)-theta(4))*varargin(5))-varargin(7)*(varargin(8)-theta(5)*varargin(1)*varargin(9)+(theta(5)*varargin(1)-theta(3))*varargin(4)-theta(4)*varargin(5)))-1/theta(2)/varargin(5)*varargin(6)*(theta(6)*varargin(2)-theta(4)),1/theta(2)/varargin(5)*(theta(1)*theta(7)*(varargin(9)-varargin(3))-varargin(8)+theta(6)*varargin(2)*varargin(9)-(theta(6)*varargin(2)-theta(4))*varargin(5)),1/theta(2)/varargin(5)*(-varargin(8)+theta(5)*varargin(1)*varargin(9)-(theta(5)*varargin(1)-theta(3))*varargin(4))];
B =[1/theta(1),-1/theta(1)*theta(6)*varargin(2);
1/theta(2),-1/theta(2)*theta(5)*varargin(1);
1/theta(1)/varargin(4)*(varargin(2)-varargin(6)-varargin(7)),1/theta(1)/varargin(4)*(varargin(6)*theta(6)*varargin(2)+theta(2)*varargin(5)*theta(8)*(varargin(2)-varargin(7))+varargin(7)*theta(5)*varargin(1));
1/theta(2)/varargin(5)*(varargin(2)-varargin(6)-varargin(7)),1/theta(2)/varargin(5)*(-theta(1)*theta(7)*(varargin(2)-varargin(6))+varargin(6)*theta(6)*varargin(2)+varargin(7)*theta(5)*varargin(1))];
C = eye(4);
D = zeros(4,2);
K = zeros(4,1);
x0 = [varargin(4); varargin(5); varargin(6); varargin(7)];


I have the following Matlab code that I try and execute:
Minit = idgrey('DMCLinearModel',[0.2502 0.1251 0.3336 0.1668 0.2196 0.2196 2.0000e-004 1.9000e-004],'c',[0.6571, 0.176, 2000, 1500, 1600, 0.13, 0.4, 28, 1550])


I get the following error when trying to run the code:

??? Error using ==> idgrey.idgrey
Error or mismatch in Mfile and Parameter or FileArgument size.
The error message is: 'Index exceeds matrix dimensions.'

Error in ==> SIDv1 at 60
Minit = idgrey('DMCLinearModel',[0.2502 0.1251 0.3336 0.1668 0.2196 0.2196 2.0000e-004 1.9000e-004],'c',[0.6571, 0.176, 2000, 1500, 1600, 0.13, 0.4, 28, 1550])


Can someone please assist me in determining what the real problem is with this so that I can get it to work?
From: Rajiv Singh on
varargin inside a MATLAB function is a cell array with one element for each
input argument passed to the function after the explicitly defined inputs
(which are theta, T in your function). In your example, varargin is a cell
array with one element that contains a double vector. Do v = varargin{1} and
then use v(1), v(2), ...v(9) in your equations.

Rajiv

"Jonathan" <jon(a)tuks.co.za> wrote in message
news:1003750004.36381.1271676027110.JavaMail.root(a)gallium.mathforum.org...
> Hi,
>
> I have a similar problem. I have the following function file:
>
> function [A,B,C,D,K,x0] = DMCLinearModel(theta,T,varargin)
> % theta(1), theta(2), theta(3), theta(4), theta(5), theta(6), theta(7),
> theta(8)
> A = [-1/theta(1)*theta(3),1/theta(1)*(theta(6)*varargin(2)-theta(4)),0,0;
> 1/theta(2)*(theta(5)*varargin(1)-theta(3)),-1/theta(2)*theta(4),0,0;
> -1/theta(1)/varargin(4)^2*(varargin(2)*varargin(8)-theta(3)*varargin(4)*varargin(6)-theta(4)*varargin(5)*varargin(7)-varargin(6)*(varargin(8)-theta(6)*varargin(2)*varargin(9)-theta(3)*varargin(4)+(theta(6)*varargin(2)-theta(4))*varargin(5))-theta(2)*varargin(5)*theta(8)*(varargin(3)-varargin(9))*(varargin(2)-varargin(7))-varargin(7)*(varargin(8)-theta(5)*varargin(1)*varargin(9)+(theta(5)*varargin(1)-theta(3))*varargin(4)-theta(4)*varargin(5)))-1/theta(1)/varargin(4)*varargin(7)*(theta(5)*varargin(1)-theta(3)),1/theta(1)/varargin(4)*(-varargin(6)*(theta(6)*varargin(2)-theta(4))-theta(2)*theta(8)*(varargin(3)-varargin(9))*(varargin(2)-varargin(7))),1/theta(1)/varargin(4)*(-varargin(8)+theta(6)*varargin(2)*varargin(9)-(theta(6)*varargin(2)-theta(4))*varargin(5)),1/theta(1)/varargin(4)*(theta(2)*varargin(5)*theta(8)*(varargin(3)-varargin(9))-varargin(8)+theta(5)*varargin(1)*varargin(9)-(theta(5)*varargin(1)-theta(3))*varargin(4));
> -1/theta(2)/varargin(5)*varargin(7)*(theta(5)*varargin(1)-theta(3)),-1/theta(2)/varargin(5)^2*(varargin(2)*varargin(8)-theta(3)*varargin(4)*varargin(6)-theta(4)*varargin(5)*varargin(7)-theta(1)*theta(7)*(varargin(9)-varargin(3))*(varargin(2)-varargin(6))-varargin(6)*(varargin(8)-theta(6)*varargin(2)*varargin(9)-theta(3)*varargin(4)+(theta(6)*varargin(2)-theta(4))*varargin(5))-varargin(7)*(varargin(8)-theta(5)*varargin(1)*varargin(9)+(theta(5)*varargin(1)-theta(3))*varargin(4)-theta(4)*varargin(5)))-1/theta(2)/varargin(5)*varargin(6)*(theta(6)*varargin(2)-theta(4)),1/theta(2)/varargin(5)*(theta(1)*theta(7)*(varargin(9)-varargin(3))-varargin(8)+theta(6)*varargin(2)*varargin(9)-(theta(6)*varargin(2)-theta(4))*varargin(5)),1/theta(2)/varargin(5)*(-varargin(8)+theta(5)*varargin(1)*varargin(9)-(theta(5)*varargin(1)-theta(3))*varargin(4))];
> B =[1/theta(1),-1/theta(1)*theta(6)*varargin(2);
> 1/theta(2),-1/theta(2)*theta(5)*varargin(1);
>
> 1/theta(1)/varargin(4)*(varargin(2)-varargin(6)-varargin(7)),1/theta(1)/varargin(4)*(varargin(6)*theta(6)*varargin(2)+theta(2)*varargin(5)*theta(8)*(varargin(2)-varargin(7))+varargin(7)*theta(5)*varargin(1));
>
> 1/theta(2)/varargin(5)*(varargin(2)-varargin(6)-varargin(7)),1/theta(2)/varargin(5)*(-theta(1)*theta(7)*(varargin(2)-varargin(6))+varargin(6)*theta(6)*varargin(2)+varargin(7)*theta(5)*varargin(1))];
> C = eye(4);
> D = zeros(4,2);
> K = zeros(4,1);
> x0 = [varargin(4); varargin(5); varargin(6); varargin(7)];
>
>
> I have the following Matlab code that I try and execute:
> Minit = idgrey('DMCLinearModel',[0.2502 0.1251 0.3336 0.1668 0.2196 0.2196
> 2.0000e-004 1.9000e-004],'c',[0.6571, 0.176, 2000, 1500, 1600, 0.13, 0.4,
> 28, 1550])
>
>
> I get the following error when trying to run the code:
>
> ??? Error using ==> idgrey.idgrey
> Error or mismatch in Mfile and Parameter or FileArgument size.
> The error message is: 'Index exceeds matrix dimensions.'
>
> Error in ==> SIDv1 at 60
> Minit = idgrey('DMCLinearModel',[0.2502 0.1251 0.3336 0.1668 0.2196 0.2196
> 2.0000e-004 1.9000e-004],'c',[0.6571, 0.176, 2000, 1500, 1600, 0.13, 0.4,
> 28, 1550])
>
>
> Can someone please assist me in determining what the real problem is with
> this so that I can get it to work?