Clear Filters
Clear Filters

Size mismatch when i am using simulink

11 views (last 30 days)
alaa
alaa on 25 Dec 2023
Commented: alaa on 27 Dec 2023
Greetings all, i am currently using simulink to do a project, however when i run the model i get this errors
1.Simulink does not have enough information to determine output sizes for this block. If you think the errors below are inaccurate, try specifying types for the block inputs and/or sizes for the block outputs.
Component:MATLAB Function | Category:Coder error
2.Size mismatch (size [1 x 3] ~= size [3 x 3]). The size to the left is the size of the left-hand side of the assignment. More informationFunction 'MATLAB Function1' (#81.979.988), line 52, column 1: "param_vec" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
3.Function call failed. Function 'MATLAB Function1' (#81.79.119), line 12, column 5: "compute_inv(x, y ,z, l1, l2,l3, epsilon)" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
4.Errors occurred during parsing of 'Robot_Arm/MATLAB Function1'.
Component:MATLAB Function | Category:Coder error
5.Simulink cannot determine sizes and/or types of the outputs for block 'Robot_Arm/MATLAB Function1' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Component:MATLAB Function | Category:Coder error
6.Simulink cannot determine sizes and/or types of the outputs for block 'Robot_Arm/MATLAB Function1' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs.
Component:Simulink | Category:Model error
7.Error in port widths or dimensions. 'Output Port 1' of 'Robot_Arm/MATLAB Function1/z' is a one dimensional vector with 1 elements.
function [t1,t2,t3] = fcn(x,y,z)
l1=0.1;
l2= 0.1;
l3=0.045;
epsilon = 0.001;
t = compute_inv(x, y ,z, l1, l2,l3, epsilon) ;
t1=t(1);
t2=t(2);
t3=t(3);
end
function f =roots_fn_inv(x,y,z,t1,t2,t3,l1,l2,l3);
f = [l1*cos(t1)*(cos(t2+t3)+cos(t2))-x;
l2*sin(t1)*(cos(t2+t3)+cos(t2))-y;
l1*sin(t2+t3)+l1*sin(t2)+l3-z;];
end
function f_dash = drev_roots_fn_inv(t1,t2,t3,l1,l2,l3);
f_dash = [-(sin(t1)*(cos(t2+t3)+cos(t2)))/10 -(cos(t1)*(sin(t2 + t3)+sin(t2)))/10 -(sin(t2 + t3)*cos(t1))/10;
(cos(t1)*(cos(t2+t3)+cos(t2)))/10 -(sin(t1)*(sin(t2 + t3)+sin(t2)))/10 -(sin(t2 + t3)*sin(t1))/10;
0 cos(t2+t3)/10+cos(t2)/10 cos(t2+t3)/10;]
end
function param_vec = compute_inv (x, y, z, l1, l2 ,l3, epsilon);
t1=pi/2;
t2=pi/2;
t3=pi/2;
readings_t1=t1;
readings_t2=t2;
readings_t3=t3;
param_vec=[t1,t2,t3];
F_n=roots_fn_inv(x,y,z,t1,t2,t3,l1,l2,l3);
n=1;
while norm(F_n) > epsilon
F_n_dash=drev_roots_fn_inv(t1, t2,t3,l1,l2,l3) ;
param_vec = param_vec - F_n_dash\F_n;
t1=param_vec(1) ;
t2=param_vec (2);
t3=param_vec (3);
F_n = roots_fn_inv(x,y,z,t1,t2,t3,l1,l2,l3);
n= n+1;
end
end

Accepted Answer

Sam Chak
Sam Chak on 27 Dec 2023
You need to perform a transpose on the param_vec vector as indicated in the code.
x = 0.1;
y = x;
z = y;
[t1, t2, t3] = fcn(x, y, z)
t1 = -153.1526
t2 = -2.8030
t3 = 4.8641
function [t1, t2, t3] = fcn(x, y, z)
l1 = 0.1;
l2 = 0.1;
l3 = 0.045;
epsilon = 0.001;
% call local function 'compute_inv()'
t = compute_inv(x, y ,z, l1, l2,l3, epsilon);
t1 = t(1);
t2 = t(2);
t3 = t(3);
%% compute_inv
function param_vec = compute_inv(x, y, z, l1, l2 ,l3, epsilon);
t1 = pi/2;
t2 = pi/2;
t3 = pi/2;
readings_t1 = t1;
readings_t2 = t2;
readings_t3 = t3;
param_vec = [t1, t2, t3]'; % <-- fix here or make it a column vector
F_n = roots_fn_inv(x, y, z, t1, t2, t3, l1, l2, l3);
n = 1;
while norm(F_n) > epsilon
F_n_dash = drev_roots_fn_inv(t1, t2, t3, l1, l2, l3);
param_vec = param_vec - F_n_dash\F_n;
t1 = param_vec(1);
t2 = param_vec(2);
t3 = param_vec(3);
F_n = roots_fn_inv(x, y, z, t1, t2, t3, l1, l2, l3);
n = n + 1;
end
end
%% roots_fn_inv
function f = roots_fn_inv(x, y, z, t1, t2, t3, l1, l2, l3)
f = [l1*cos(t1)*(cos(t2+t3)+cos(t2))-x;
l2*sin(t1)*(cos(t2+t3)+cos(t2))-y;
l1*sin(t2+t3)+l1*sin(t2)+l3-z];
end
%% drev_roots_fn_inv
function f_dash = drev_roots_fn_inv(t1, t2, t3, l1, l2, l3)
f_dash = [-(sin(t1)*(cos(t2+t3)+cos(t2)))/10 -(cos(t1)*(sin(t2 + t3)+sin(t2)))/10 -(sin(t2 + t3)*cos(t1))/10;
(cos(t1)*(cos(t2+t3)+cos(t2)))/10 -(sin(t1)*(sin(t2 + t3)+sin(t2)))/10 -(sin(t2 + t3)*sin(t1))/10;
0 cos(t2+t3)/10+cos(t2)/10 cos(t2+t3)/10];
end
end

More Answers (0)

Categories

Find more on Equations in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!