Category: Matlab
Category Archives: Matlab
Error calling … This call-site expects more outputs than this function can supply. P-code function ‘checkNonlinearInputs.p’ produced an error.
Good evening,
I am currently working on a parallelipiped driving simulator with 3-DoF (heave, roll and pitch) that has 4 actuators on the corners, so I cannot use inverse kinematic to obtain the length of the four actuators (z1 is the rear right actuator, z2 front right and so on anti clockwise). So I decided to use Maple to write the kinematic solution (the varibles with subscript g) and the constraints, and to use a constrained minimization to find the length of actuators. However, if I use a single target to try the optimization(theta_t, phi_t, z_t), Simulink does not signal any error while using a trajectory of more points, Simulink gives me the following error "Error calling ‘Opt/mycon’. This call-site expects more outputs than this function can supply. P-code function ‘checkNonlinearInputs.p’ produced an error.". I leave the code of the MATLAB function block below, which receives as input the two angles and the heave and has as output the four actuators length. How can I solve this problem to obtain a workink real-time optimization? Thanks in advance.
function [z1, z2, z3, z4] = Opt(theta_t, phi_t, z_t)
l = 0.82;
L = 1.6;
% theta_t = 1.5*pi/180;
% phi_t = 1.5*pi/180;
% z_t = 0.05;
%theta_g = atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2));
%phi_g = -atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l));
% x_g = ((-2*z(3) + 2*z(4))*z(1) + L^2)/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2));
% y_g = ((-z(3)^2 + (-2*z(1) + z(2) + z(4))*z(3) + l^2 + 2*z(1)*z(2) – z(2)*z(4))*L^2 + l^2*(z(3) – z(4))^2)/(2*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l);
% z_g = L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
fun = @(z)120*(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)) – theta_t)^2 + 40*(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)) – phi_t)^2 …
+ 1*(L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) +1*(l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))) – z_t)^2;
lb = [0, 0, 0, 0];
ub = [0.1, 0.1, 0.1, 0.1];
if theta_t < 0.4*pi/180
options = optimoptions(‘fmincon’,’Display’,’iter’,’Algorithm’,’sqp’, ‘ConstraintTolerance’, 1e-17, ‘StepTolerance’, 1e-10);
else
options = optimoptions(‘fmincon’,’Display’,’iter’,’Algorithm’,’sqp’, ‘ConstraintTolerance’, 1e-18, ‘StepTolerance’, 1e-10);
end
function [c,ceq] = mycon(z)
l = 0.82;
L = 1.6;
c = [atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)) – 3.5*pi/180;
-atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)) – 3.5*pi/180;
-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)) – 2.5*pi/180;
-(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) – 2.5*pi/180];
ceq = [-sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(1) – 0.8000000000*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) + ((-2*z(3) + 2*z(4))*z(1) + L^2)/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2));
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(2) – 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) – 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(3) – 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) + 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(4) + 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) + 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(1) – 0.8000000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) – 0.4100000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + ((-z(3)^2 + (-2*z(1) + z(2) + z(4))*z(3) + l^2 + 2*z(1)*z(2) – z(2)*z(4))*L^2 + l^2*(z(3) – z(4))^2)/(2*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l);
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(1) + 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) – 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
];
end
Z = fmincon(fun, [0.05, 0.05, 0.05, 0.05], [], [], [], [], lb, ub , @mycon, options);
z1 = Z(1);
z2 = Z(2);
z3 = Z(3);
z4 = Z(4);
endGood evening,
I am currently working on a parallelipiped driving simulator with 3-DoF (heave, roll and pitch) that has 4 actuators on the corners, so I cannot use inverse kinematic to obtain the length of the four actuators (z1 is the rear right actuator, z2 front right and so on anti clockwise). So I decided to use Maple to write the kinematic solution (the varibles with subscript g) and the constraints, and to use a constrained minimization to find the length of actuators. However, if I use a single target to try the optimization(theta_t, phi_t, z_t), Simulink does not signal any error while using a trajectory of more points, Simulink gives me the following error "Error calling ‘Opt/mycon’. This call-site expects more outputs than this function can supply. P-code function ‘checkNonlinearInputs.p’ produced an error.". I leave the code of the MATLAB function block below, which receives as input the two angles and the heave and has as output the four actuators length. How can I solve this problem to obtain a workink real-time optimization? Thanks in advance.
function [z1, z2, z3, z4] = Opt(theta_t, phi_t, z_t)
l = 0.82;
L = 1.6;
% theta_t = 1.5*pi/180;
% phi_t = 1.5*pi/180;
% z_t = 0.05;
%theta_g = atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2));
%phi_g = -atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l));
% x_g = ((-2*z(3) + 2*z(4))*z(1) + L^2)/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2));
% y_g = ((-z(3)^2 + (-2*z(1) + z(2) + z(4))*z(3) + l^2 + 2*z(1)*z(2) – z(2)*z(4))*L^2 + l^2*(z(3) – z(4))^2)/(2*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l);
% z_g = L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
fun = @(z)120*(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)) – theta_t)^2 + 40*(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)) – phi_t)^2 …
+ 1*(L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) +1*(l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))) – z_t)^2;
lb = [0, 0, 0, 0];
ub = [0.1, 0.1, 0.1, 0.1];
if theta_t < 0.4*pi/180
options = optimoptions(‘fmincon’,’Display’,’iter’,’Algorithm’,’sqp’, ‘ConstraintTolerance’, 1e-17, ‘StepTolerance’, 1e-10);
else
options = optimoptions(‘fmincon’,’Display’,’iter’,’Algorithm’,’sqp’, ‘ConstraintTolerance’, 1e-18, ‘StepTolerance’, 1e-10);
end
function [c,ceq] = mycon(z)
l = 0.82;
L = 1.6;
c = [atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)) – 3.5*pi/180;
-atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)) – 3.5*pi/180;
-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)) – 2.5*pi/180;
-(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) – 2.5*pi/180];
ceq = [-sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(1) – 0.8000000000*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) + ((-2*z(3) + 2*z(4))*z(1) + L^2)/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2));
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(2) – 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) – 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(3) – 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) + 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(4) + 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) + 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(1) – 0.8000000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) – 0.4100000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + ((-z(3)^2 + (-2*z(1) + z(2) + z(4))*z(3) + l^2 + 2*z(1)*z(2) – z(2)*z(4))*L^2 + l^2*(z(3) – z(4))^2)/(2*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l);
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(1) + 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) – 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
];
end
Z = fmincon(fun, [0.05, 0.05, 0.05, 0.05], [], [], [], [], lb, ub , @mycon, options);
z1 = Z(1);
z2 = Z(2);
z3 = Z(3);
z4 = Z(4);
end Good evening,
I am currently working on a parallelipiped driving simulator with 3-DoF (heave, roll and pitch) that has 4 actuators on the corners, so I cannot use inverse kinematic to obtain the length of the four actuators (z1 is the rear right actuator, z2 front right and so on anti clockwise). So I decided to use Maple to write the kinematic solution (the varibles with subscript g) and the constraints, and to use a constrained minimization to find the length of actuators. However, if I use a single target to try the optimization(theta_t, phi_t, z_t), Simulink does not signal any error while using a trajectory of more points, Simulink gives me the following error "Error calling ‘Opt/mycon’. This call-site expects more outputs than this function can supply. P-code function ‘checkNonlinearInputs.p’ produced an error.". I leave the code of the MATLAB function block below, which receives as input the two angles and the heave and has as output the four actuators length. How can I solve this problem to obtain a workink real-time optimization? Thanks in advance.
function [z1, z2, z3, z4] = Opt(theta_t, phi_t, z_t)
l = 0.82;
L = 1.6;
% theta_t = 1.5*pi/180;
% phi_t = 1.5*pi/180;
% z_t = 0.05;
%theta_g = atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2));
%phi_g = -atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l));
% x_g = ((-2*z(3) + 2*z(4))*z(1) + L^2)/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2));
% y_g = ((-z(3)^2 + (-2*z(1) + z(2) + z(4))*z(3) + l^2 + 2*z(1)*z(2) – z(2)*z(4))*L^2 + l^2*(z(3) – z(4))^2)/(2*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l);
% z_g = L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
fun = @(z)120*(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)) – theta_t)^2 + 40*(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)) – phi_t)^2 …
+ 1*(L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) +1*(l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))) – z_t)^2;
lb = [0, 0, 0, 0];
ub = [0.1, 0.1, 0.1, 0.1];
if theta_t < 0.4*pi/180
options = optimoptions(‘fmincon’,’Display’,’iter’,’Algorithm’,’sqp’, ‘ConstraintTolerance’, 1e-17, ‘StepTolerance’, 1e-10);
else
options = optimoptions(‘fmincon’,’Display’,’iter’,’Algorithm’,’sqp’, ‘ConstraintTolerance’, 1e-18, ‘StepTolerance’, 1e-10);
end
function [c,ceq] = mycon(z)
l = 0.82;
L = 1.6;
c = [atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)) – 3.5*pi/180;
-atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)) – 3.5*pi/180;
-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)) – 2.5*pi/180;
-(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) – 2.5*pi/180];
ceq = [-sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(1) – 0.8000000000*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) + ((-2*z(3) + 2*z(4))*z(1) + L^2)/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2));
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(2) – 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) – 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(3) – 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) + 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(4) + 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) + 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(1) – 0.8000000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) – 0.4100000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + ((-z(3)^2 + (-2*z(1) + z(2) + z(4))*z(3) + l^2 + 2*z(1)*z(2) – z(2)*z(4))*L^2 + l^2*(z(3) – z(4))^2)/(2*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l);
-cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*cos(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)))*z(1) + 0.8000000000*cos(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l)))*sin(atan(-(z(3) – z(4))/sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))) – 0.4100000000*sin(-atan(L*(z(2) – z(3))/(sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*l))) + L*(z(2) + z(4))/(2*sqrt(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2)*sqrt(((L^2 + l^2)*z(3)^2 + (-2*L^2*z(2) – 2*l^2*z(4))*z(3) + (l^2 + z(2)^2)*L^2 + l^2*z(4)^2)/(l^2*(L^2 + z(3)^2 – 2*z(3)*z(4) + z(4)^2))));
];
end
Z = fmincon(fun, [0.05, 0.05, 0.05, 0.05], [], [], [], [], lb, ub , @mycon, options);
z1 = Z(1);
z2 = Z(2);
z3 = Z(3);
z4 = Z(4);
end real time optimization MATLAB Answers — New Questions
Arduino Uno /Simulink: Sample Time not updating with different values
Figure 1: Simulink Model Figure 2: Sample Time @ 0.01
I am using Simulink (R2024a). I am using a pendulum to try to purposely get a scope of aliasing with the signal coming from the Arduino Uno. When I input the SampleTime (0.01), the program outputs a sine wave as expected.
Figure 3: Sine Wave at Sample Time @ 0.01 & Stop Time @10.0
When I change the Stop Time to 30.0 sec and ensure the Simulation pacing is 1:1, it outputs a sine wave and runs the whole simulation.
Figure 4: Sine Wave Sample Time @ 0.01 & StopTime @ 30.0
However, when I change the Sample time to any other value, the program doesn’t work as intended. The simulation is done in 1 sec even though the Simulation Pacing is a 1:1 ratio. It does get some aliasing, but it looks very incomplete.
Figure 5: Incomplete Aliasing with Sample Time @ 1.0 & Stop Time @ 30.0
The end result is supposed to look like this.
Figure 6: Goal of Aliasing graph on older MATLAB release
The diagnostic viewer reports no errors.
I have alternated with using different hardware (arduino board vs computer) and they both do not run correctly. I have experimented with different Sample Times, Stop Times, and 3D Array/Timespace/2DArrays (To Workspace) with no change or success.
I am thinking it has something to do with the updated version vs the older version that this experiment was based on.Figure 1: Simulink Model Figure 2: Sample Time @ 0.01
I am using Simulink (R2024a). I am using a pendulum to try to purposely get a scope of aliasing with the signal coming from the Arduino Uno. When I input the SampleTime (0.01), the program outputs a sine wave as expected.
Figure 3: Sine Wave at Sample Time @ 0.01 & Stop Time @10.0
When I change the Stop Time to 30.0 sec and ensure the Simulation pacing is 1:1, it outputs a sine wave and runs the whole simulation.
Figure 4: Sine Wave Sample Time @ 0.01 & StopTime @ 30.0
However, when I change the Sample time to any other value, the program doesn’t work as intended. The simulation is done in 1 sec even though the Simulation Pacing is a 1:1 ratio. It does get some aliasing, but it looks very incomplete.
Figure 5: Incomplete Aliasing with Sample Time @ 1.0 & Stop Time @ 30.0
The end result is supposed to look like this.
Figure 6: Goal of Aliasing graph on older MATLAB release
The diagnostic viewer reports no errors.
I have alternated with using different hardware (arduino board vs computer) and they both do not run correctly. I have experimented with different Sample Times, Stop Times, and 3D Array/Timespace/2DArrays (To Workspace) with no change or success.
I am thinking it has something to do with the updated version vs the older version that this experiment was based on. Figure 1: Simulink Model Figure 2: Sample Time @ 0.01
I am using Simulink (R2024a). I am using a pendulum to try to purposely get a scope of aliasing with the signal coming from the Arduino Uno. When I input the SampleTime (0.01), the program outputs a sine wave as expected.
Figure 3: Sine Wave at Sample Time @ 0.01 & Stop Time @10.0
When I change the Stop Time to 30.0 sec and ensure the Simulation pacing is 1:1, it outputs a sine wave and runs the whole simulation.
Figure 4: Sine Wave Sample Time @ 0.01 & StopTime @ 30.0
However, when I change the Sample time to any other value, the program doesn’t work as intended. The simulation is done in 1 sec even though the Simulation Pacing is a 1:1 ratio. It does get some aliasing, but it looks very incomplete.
Figure 5: Incomplete Aliasing with Sample Time @ 1.0 & Stop Time @ 30.0
The end result is supposed to look like this.
Figure 6: Goal of Aliasing graph on older MATLAB release
The diagnostic viewer reports no errors.
I have alternated with using different hardware (arduino board vs computer) and they both do not run correctly. I have experimented with different Sample Times, Stop Times, and 3D Array/Timespace/2DArrays (To Workspace) with no change or success.
I am thinking it has something to do with the updated version vs the older version that this experiment was based on. matlab, simulink, arduino MATLAB Answers — New Questions
not enough input arguments when using function functions.
Hi, when I call heun(u0,n,dt,f), the error is:
Not enough input arguments.
Error in f (line 7)
mat = zeros(n);
Any ideas why? It’s like the f function hasn’t even read the parameters I put into it.
Thanks.Hi, when I call heun(u0,n,dt,f), the error is:
Not enough input arguments.
Error in f (line 7)
mat = zeros(n);
Any ideas why? It’s like the f function hasn’t even read the parameters I put into it.
Thanks. Hi, when I call heun(u0,n,dt,f), the error is:
Not enough input arguments.
Error in f (line 7)
mat = zeros(n);
Any ideas why? It’s like the f function hasn’t even read the parameters I put into it.
Thanks. function functions, matlab MATLAB Answers — New Questions
Why does my third-party scheduler .conf not appear when attempting to Discover Clusters?
Why does my third-party scheduler .conf not appear when attempting to Discover Clusters?Why does my third-party scheduler .conf not appear when attempting to Discover Clusters? Why does my third-party scheduler .conf not appear when attempting to Discover Clusters? MATLAB Answers — New Questions
How to make different NumberFormat in two columns (using Matlab Report Generator)
Hello! I need to make a table in which one column has NumberFormat("%1.8f") and other has NumberFormat("%1.1f"). I can’t figure it out. I tried to make 2 tables with different styles and then combine them, but it makes separate tables in word document (look at the photo). Here’s the code:
tableStyles1 = { ColSep("solid"), …
RowSep("solid"), …
Border("solid"), …
NumberFormat("%1.8f")};
tableStyles2 = { ColSep("solid"), …
RowSep("solid"), …
Border("solid"), …
NumberFormat("%1.1f")};
Stat_table1 = FormalTable(Tide_const(:,1));
Stat_table2 = FormalTable(Tide_const(:,2));
Stat_table1.Style = [Stat_table1.Style, tableStyles1];
Stat_table2.Style = [Stat_table2.Style, tableStyles2];
Table_gen = FormalTable([Stat_table1 Stat_table2]);
append(sec1,Table_gen);Hello! I need to make a table in which one column has NumberFormat("%1.8f") and other has NumberFormat("%1.1f"). I can’t figure it out. I tried to make 2 tables with different styles and then combine them, but it makes separate tables in word document (look at the photo). Here’s the code:
tableStyles1 = { ColSep("solid"), …
RowSep("solid"), …
Border("solid"), …
NumberFormat("%1.8f")};
tableStyles2 = { ColSep("solid"), …
RowSep("solid"), …
Border("solid"), …
NumberFormat("%1.1f")};
Stat_table1 = FormalTable(Tide_const(:,1));
Stat_table2 = FormalTable(Tide_const(:,2));
Stat_table1.Style = [Stat_table1.Style, tableStyles1];
Stat_table2.Style = [Stat_table2.Style, tableStyles2];
Table_gen = FormalTable([Stat_table1 Stat_table2]);
append(sec1,Table_gen); Hello! I need to make a table in which one column has NumberFormat("%1.8f") and other has NumberFormat("%1.1f"). I can’t figure it out. I tried to make 2 tables with different styles and then combine them, but it makes separate tables in word document (look at the photo). Here’s the code:
tableStyles1 = { ColSep("solid"), …
RowSep("solid"), …
Border("solid"), …
NumberFormat("%1.8f")};
tableStyles2 = { ColSep("solid"), …
RowSep("solid"), …
Border("solid"), …
NumberFormat("%1.1f")};
Stat_table1 = FormalTable(Tide_const(:,1));
Stat_table2 = FormalTable(Tide_const(:,2));
Stat_table1.Style = [Stat_table1.Style, tableStyles1];
Stat_table2.Style = [Stat_table2.Style, tableStyles2];
Table_gen = FormalTable([Stat_table1 Stat_table2]);
append(sec1,Table_gen); report generator, table format MATLAB Answers — New Questions
Can’t run script in namespace directory
Hello,
why is it that one apparently can’t run scripts that are placed in namespace directories, i.e. direcotries that have their name start with a + ?
The reason I have a script in a namespace is that it containes some examples of how to use the code in the namespace. (It also seems like it’s not possible to add a namespace directory to the path.)Hello,
why is it that one apparently can’t run scripts that are placed in namespace directories, i.e. direcotries that have their name start with a + ?
The reason I have a script in a namespace is that it containes some examples of how to use the code in the namespace. (It also seems like it’s not possible to add a namespace directory to the path.) Hello,
why is it that one apparently can’t run scripts that are placed in namespace directories, i.e. direcotries that have their name start with a + ?
The reason I have a script in a namespace is that it containes some examples of how to use the code in the namespace. (It also seems like it’s not possible to add a namespace directory to the path.) path, namespace MATLAB Answers — New Questions
How can I put a custom colorbar into a figure with multiple datasets/datatypes
I have an interesting situation where I am trying to overlay 3 different datatypes and make a custom colorbar for one of them.
For context, it first has and RBG image loaded using imagesc, scaled to lat/lon limits. The colors of the image are supposed to correlate with concentration and this is what I which to display in the color bar (the dark green to bright yellow).
Secondly, it has two contours (contourf): one for the depth contours and one for the coastline. This is overlayed so that it lines up with the RGB image. These contours also have their own colormap
Finally, it has 3 sets of data plotted using just ‘plot’ overtop of that.
I have created a custom color set corresponding to the range of colors in the RGB image, but I need the land and everything else to follow a different colormap. I also need to somehow scale the colorbar output to the corresponding concentrations. Currently, the colorbar only uses the depth data, and changing the colormap changes the colormap of all data sets. I hope the images below make the issue more clear.
I would like the colorbar to have the colors of the first picture, but scaled to the concentrations and not depth. And I would like the rest of the image to look like the second picture.
Thank you in advance! And sorry if this isn’t super clear.
SeanI have an interesting situation where I am trying to overlay 3 different datatypes and make a custom colorbar for one of them.
For context, it first has and RBG image loaded using imagesc, scaled to lat/lon limits. The colors of the image are supposed to correlate with concentration and this is what I which to display in the color bar (the dark green to bright yellow).
Secondly, it has two contours (contourf): one for the depth contours and one for the coastline. This is overlayed so that it lines up with the RGB image. These contours also have their own colormap
Finally, it has 3 sets of data plotted using just ‘plot’ overtop of that.
I have created a custom color set corresponding to the range of colors in the RGB image, but I need the land and everything else to follow a different colormap. I also need to somehow scale the colorbar output to the corresponding concentrations. Currently, the colorbar only uses the depth data, and changing the colormap changes the colormap of all data sets. I hope the images below make the issue more clear.
I would like the colorbar to have the colors of the first picture, but scaled to the concentrations and not depth. And I would like the rest of the image to look like the second picture.
Thank you in advance! And sorry if this isn’t super clear.
Sean I have an interesting situation where I am trying to overlay 3 different datatypes and make a custom colorbar for one of them.
For context, it first has and RBG image loaded using imagesc, scaled to lat/lon limits. The colors of the image are supposed to correlate with concentration and this is what I which to display in the color bar (the dark green to bright yellow).
Secondly, it has two contours (contourf): one for the depth contours and one for the coastline. This is overlayed so that it lines up with the RGB image. These contours also have their own colormap
Finally, it has 3 sets of data plotted using just ‘plot’ overtop of that.
I have created a custom color set corresponding to the range of colors in the RGB image, but I need the land and everything else to follow a different colormap. I also need to somehow scale the colorbar output to the corresponding concentrations. Currently, the colorbar only uses the depth data, and changing the colormap changes the colormap of all data sets. I hope the images below make the issue more clear.
I would like the colorbar to have the colors of the first picture, but scaled to the concentrations and not depth. And I would like the rest of the image to look like the second picture.
Thank you in advance! And sorry if this isn’t super clear.
Sean colormap, colorbar, contour MATLAB Answers — New Questions
I am getting this warning “Matrix is singular to working precision.” and my surf plot is not showing.
I want to plot the 3D plot for the following function , where and . I tried ploting with the code attached, but i am not getting a surface plot.I want to plot the 3D plot for the following function , where and . I tried ploting with the code attached, but i am not getting a surface plot. I want to plot the 3D plot for the following function , where and . I tried ploting with the code attached, but i am not getting a surface plot. exact and interpolation MATLAB Answers — New Questions
HDL Tool setup issue
hdlsetuptoolpath(‘ToolName’,’Xilinx Vivado’,’ToolPath’,…
‘E:XilinxVivado2023.1binvivado.bat’);
Error using setupToolPath
File or directory path ‘E:XilinxVivado2023.1binvivado.bat’ does not exist from current working directory.
Error in setupToolPath
Error in hdlsetuptoolpath (line 48)
setupToolPath(varargin{:});
I am facing this issue while linking the Matlab with xilinx even i have compatible versions of Matlab and Xilinx Vivado but unable to get the compatibility between them, as well as while choosing the path from the matlab unable to get the VIVADO.bat file for matlab, i am facing this issue from so many days.hdlsetuptoolpath(‘ToolName’,’Xilinx Vivado’,’ToolPath’,…
‘E:XilinxVivado2023.1binvivado.bat’);
Error using setupToolPath
File or directory path ‘E:XilinxVivado2023.1binvivado.bat’ does not exist from current working directory.
Error in setupToolPath
Error in hdlsetuptoolpath (line 48)
setupToolPath(varargin{:});
I am facing this issue while linking the Matlab with xilinx even i have compatible versions of Matlab and Xilinx Vivado but unable to get the compatibility between them, as well as while choosing the path from the matlab unable to get the VIVADO.bat file for matlab, i am facing this issue from so many days. hdlsetuptoolpath(‘ToolName’,’Xilinx Vivado’,’ToolPath’,…
‘E:XilinxVivado2023.1binvivado.bat’);
Error using setupToolPath
File or directory path ‘E:XilinxVivado2023.1binvivado.bat’ does not exist from current working directory.
Error in setupToolPath
Error in hdlsetuptoolpath (line 48)
setupToolPath(varargin{:});
I am facing this issue while linking the Matlab with xilinx even i have compatible versions of Matlab and Xilinx Vivado but unable to get the compatibility between them, as well as while choosing the path from the matlab unable to get the VIVADO.bat file for matlab, i am facing this issue from so many days. matlab, xilinx, fpga MATLAB Answers — New Questions
raytracing channel on matlab
Hello everyone, I am analyzing a real urban environment taken from open street map (like google maps). In this I am looking at multipath propagation through the raytracing model, where I create the multipath channel between transmitters and receiver moving through the comm.RayTracingChannel object. Since I am not providing any signal as an input to the channel, what the channel returns to me is an array in which there are samples that describe the multipath to me. What I would like to know is whether what is returned to me is the impulsive response of the channel, or simply an array of samples describing to me the power trend due to the fading generated by the doppler effect. I think it is this second option, but I would like some confirmation.Hello everyone, I am analyzing a real urban environment taken from open street map (like google maps). In this I am looking at multipath propagation through the raytracing model, where I create the multipath channel between transmitters and receiver moving through the comm.RayTracingChannel object. Since I am not providing any signal as an input to the channel, what the channel returns to me is an array in which there are samples that describe the multipath to me. What I would like to know is whether what is returned to me is the impulsive response of the channel, or simply an array of samples describing to me the power trend due to the fading generated by the doppler effect. I think it is this second option, but I would like some confirmation. Hello everyone, I am analyzing a real urban environment taken from open street map (like google maps). In this I am looking at multipath propagation through the raytracing model, where I create the multipath channel between transmitters and receiver moving through the comm.RayTracingChannel object. Since I am not providing any signal as an input to the channel, what the channel returns to me is an array in which there are samples that describe the multipath to me. What I would like to know is whether what is returned to me is the impulsive response of the channel, or simply an array of samples describing to me the power trend due to the fading generated by the doppler effect. I think it is this second option, but I would like some confirmation. raytracing, raytracing channel, channel impulse response MATLAB Answers — New Questions
Ground penetrating radar processing in MATLAB
Can anyone suggest how to process GPR .rd3 file in matlabCan anyone suggest how to process GPR .rd3 file in matlab Can anyone suggest how to process GPR .rd3 file in matlab gpr MATLAB Answers — New Questions
‘matlab.System’ cannot be found in Signal Processing Toolbox Support Package for Linux IIO Devices
I am creating a standalone desktop app with Matlab compiler. My app utilizes the Signal Processing Toolbox Support Package for Linux IIO Devices with the matlabshared.libiio.sharedmem.read() function. When utilizing the compiler, it gives suggestions for files to be included and thus includes the read.p file. It gave a warning that dependencies for .p file cannot be scanned, which I think is relevant to the issue. When I try to launch the standalone app, I get the error: the specified superclass "matlab.System" contains a parse error, cannot be found on MATLAB’s search path, or is shadowed by a file with the same name. I don’t have much experience working with this package but my guess is that read.p references matlab.System. I am not sure how to resolve this. ThanksI am creating a standalone desktop app with Matlab compiler. My app utilizes the Signal Processing Toolbox Support Package for Linux IIO Devices with the matlabshared.libiio.sharedmem.read() function. When utilizing the compiler, it gives suggestions for files to be included and thus includes the read.p file. It gave a warning that dependencies for .p file cannot be scanned, which I think is relevant to the issue. When I try to launch the standalone app, I get the error: the specified superclass "matlab.System" contains a parse error, cannot be found on MATLAB’s search path, or is shadowed by a file with the same name. I don’t have much experience working with this package but my guess is that read.p references matlab.System. I am not sure how to resolve this. Thanks I am creating a standalone desktop app with Matlab compiler. My app utilizes the Signal Processing Toolbox Support Package for Linux IIO Devices with the matlabshared.libiio.sharedmem.read() function. When utilizing the compiler, it gives suggestions for files to be included and thus includes the read.p file. It gave a warning that dependencies for .p file cannot be scanned, which I think is relevant to the issue. When I try to launch the standalone app, I get the error: the specified superclass "matlab.System" contains a parse error, cannot be found on MATLAB’s search path, or is shadowed by a file with the same name. I don’t have much experience working with this package but my guess is that read.p references matlab.System. I am not sure how to resolve this. Thanks matlab.system, matlab compiler, linux iio MATLAB Answers — New Questions
How to band pass filter the EMG signal in real time?
%#######################################
% In signal processing, the power spectrum of a continuous time signal describes
% the distribution of power into frequency components. composing that signal. According to Fourier analysis,
% any physical signal can be decomposed into a number of discrete frequencies,
% or a spectrum of frequencies over a continuous range.
% Get the full wave rectification of the EMG signal by measuring it’s
% absolute value.
% ######################################
clc;
clear;
close all;
% Parameters
sampling_frequency = 1000; % Sampling frequency in Hz
duration = 5; % Duration of signal acquisition in seconds
num_samples = sampling_frequency * duration; % Sampling_frequency = (No. of Samples) / Time Interval
% Initialize variables
time = (0:num_samples-1)/sampling_frequency;
frequency = linspace(0, sampling_frequency/2, num_samples/2);
x = zeros(1, num_samples);
a = arduino(); % Check port from device manager and pin is A0
% Create figure for real-time EMG signal
figure(‘Name’, ‘Real-Time EMG Signal Visualization’);
h_real_time = plot(time, x);
grid on;
title(‘Real-Time EMG Signal’);
xlabel(‘Time (s)’);
ylabel(‘Voltage (V)’);
xlim([0, duration]); % Adjust xlim as needed
ylim([0, 3]); % Adjust ylim as needed
% Create figure for spectrogram
figure(‘Name’, ‘Real-Time Spectrogram EMG Signal Visualization’);
h_spectrogram = imagesc(‘XData’, [], ‘YData’, [], ‘CData’, []);
axis xy;
xlabel(‘Time (s)’);
ylabel(‘Frequency (Hz)’);
title(‘Spectrogram of EMG Signal’);
colorbar;
% Pre-allocate spectrogram variables
Nspec = 256; % Spectrogram window size
overlap = round(Nspec * 0.85); % 85% overlap
% Filter parameters
filter_order = 4; % Filter order
bandpass_low_cutoff = 10; % Bandpass low cutoff frequency in Hz
bandpass_high_cutoff = 500; % Bandpass high cutoff frequency in Hz
% Design Butterworth bandpass filter
assert(filter_order > 0 && round(filter_order) == filter_order, ‘Filter order must be a positive integer’);
Wn = [bandpass_low_cutoff, bandpass_high_cutoff] / (sampling_frequency / 2);
[b, a] = butter(filter_order, Wn, ‘bandpass’);
% Start loop to acquire signal
for i = 1:num_samples
% Read voltage
voltage = abs(readVoltage(a, ‘A0’));
% Store voltage
x(i) = voltage;
% Update real-time plot
set(h_real_time,’YData’,abs(x));
set(h_real_time,’XData’,time);
drawnow;
% Apply bandpass filtering
if i > filter_order
x_filtered = filtfilt(b, a, abs(x(1:i)));
% Calculate spectrogram for the current signal
if i > Nspec
[S, F, T] = spectrogram(x_filtered, hamming(Nspec), overlap, Nspec, sampling_frequency, ‘yaxis’);
% Update the spectrogram
set(h_spectrogram, ‘XData’, T, ‘YData’, F, ‘CData’, 10*log10(abs(S)));
end
end
drawnow;
end
How do I band pass this signal? And is it right to rectify it after I bandpass filter it?%#######################################
% In signal processing, the power spectrum of a continuous time signal describes
% the distribution of power into frequency components. composing that signal. According to Fourier analysis,
% any physical signal can be decomposed into a number of discrete frequencies,
% or a spectrum of frequencies over a continuous range.
% Get the full wave rectification of the EMG signal by measuring it’s
% absolute value.
% ######################################
clc;
clear;
close all;
% Parameters
sampling_frequency = 1000; % Sampling frequency in Hz
duration = 5; % Duration of signal acquisition in seconds
num_samples = sampling_frequency * duration; % Sampling_frequency = (No. of Samples) / Time Interval
% Initialize variables
time = (0:num_samples-1)/sampling_frequency;
frequency = linspace(0, sampling_frequency/2, num_samples/2);
x = zeros(1, num_samples);
a = arduino(); % Check port from device manager and pin is A0
% Create figure for real-time EMG signal
figure(‘Name’, ‘Real-Time EMG Signal Visualization’);
h_real_time = plot(time, x);
grid on;
title(‘Real-Time EMG Signal’);
xlabel(‘Time (s)’);
ylabel(‘Voltage (V)’);
xlim([0, duration]); % Adjust xlim as needed
ylim([0, 3]); % Adjust ylim as needed
% Create figure for spectrogram
figure(‘Name’, ‘Real-Time Spectrogram EMG Signal Visualization’);
h_spectrogram = imagesc(‘XData’, [], ‘YData’, [], ‘CData’, []);
axis xy;
xlabel(‘Time (s)’);
ylabel(‘Frequency (Hz)’);
title(‘Spectrogram of EMG Signal’);
colorbar;
% Pre-allocate spectrogram variables
Nspec = 256; % Spectrogram window size
overlap = round(Nspec * 0.85); % 85% overlap
% Filter parameters
filter_order = 4; % Filter order
bandpass_low_cutoff = 10; % Bandpass low cutoff frequency in Hz
bandpass_high_cutoff = 500; % Bandpass high cutoff frequency in Hz
% Design Butterworth bandpass filter
assert(filter_order > 0 && round(filter_order) == filter_order, ‘Filter order must be a positive integer’);
Wn = [bandpass_low_cutoff, bandpass_high_cutoff] / (sampling_frequency / 2);
[b, a] = butter(filter_order, Wn, ‘bandpass’);
% Start loop to acquire signal
for i = 1:num_samples
% Read voltage
voltage = abs(readVoltage(a, ‘A0’));
% Store voltage
x(i) = voltage;
% Update real-time plot
set(h_real_time,’YData’,abs(x));
set(h_real_time,’XData’,time);
drawnow;
% Apply bandpass filtering
if i > filter_order
x_filtered = filtfilt(b, a, abs(x(1:i)));
% Calculate spectrogram for the current signal
if i > Nspec
[S, F, T] = spectrogram(x_filtered, hamming(Nspec), overlap, Nspec, sampling_frequency, ‘yaxis’);
% Update the spectrogram
set(h_spectrogram, ‘XData’, T, ‘YData’, F, ‘CData’, 10*log10(abs(S)));
end
end
drawnow;
end
How do I band pass this signal? And is it right to rectify it after I bandpass filter it? %#######################################
% In signal processing, the power spectrum of a continuous time signal describes
% the distribution of power into frequency components. composing that signal. According to Fourier analysis,
% any physical signal can be decomposed into a number of discrete frequencies,
% or a spectrum of frequencies over a continuous range.
% Get the full wave rectification of the EMG signal by measuring it’s
% absolute value.
% ######################################
clc;
clear;
close all;
% Parameters
sampling_frequency = 1000; % Sampling frequency in Hz
duration = 5; % Duration of signal acquisition in seconds
num_samples = sampling_frequency * duration; % Sampling_frequency = (No. of Samples) / Time Interval
% Initialize variables
time = (0:num_samples-1)/sampling_frequency;
frequency = linspace(0, sampling_frequency/2, num_samples/2);
x = zeros(1, num_samples);
a = arduino(); % Check port from device manager and pin is A0
% Create figure for real-time EMG signal
figure(‘Name’, ‘Real-Time EMG Signal Visualization’);
h_real_time = plot(time, x);
grid on;
title(‘Real-Time EMG Signal’);
xlabel(‘Time (s)’);
ylabel(‘Voltage (V)’);
xlim([0, duration]); % Adjust xlim as needed
ylim([0, 3]); % Adjust ylim as needed
% Create figure for spectrogram
figure(‘Name’, ‘Real-Time Spectrogram EMG Signal Visualization’);
h_spectrogram = imagesc(‘XData’, [], ‘YData’, [], ‘CData’, []);
axis xy;
xlabel(‘Time (s)’);
ylabel(‘Frequency (Hz)’);
title(‘Spectrogram of EMG Signal’);
colorbar;
% Pre-allocate spectrogram variables
Nspec = 256; % Spectrogram window size
overlap = round(Nspec * 0.85); % 85% overlap
% Filter parameters
filter_order = 4; % Filter order
bandpass_low_cutoff = 10; % Bandpass low cutoff frequency in Hz
bandpass_high_cutoff = 500; % Bandpass high cutoff frequency in Hz
% Design Butterworth bandpass filter
assert(filter_order > 0 && round(filter_order) == filter_order, ‘Filter order must be a positive integer’);
Wn = [bandpass_low_cutoff, bandpass_high_cutoff] / (sampling_frequency / 2);
[b, a] = butter(filter_order, Wn, ‘bandpass’);
% Start loop to acquire signal
for i = 1:num_samples
% Read voltage
voltage = abs(readVoltage(a, ‘A0’));
% Store voltage
x(i) = voltage;
% Update real-time plot
set(h_real_time,’YData’,abs(x));
set(h_real_time,’XData’,time);
drawnow;
% Apply bandpass filtering
if i > filter_order
x_filtered = filtfilt(b, a, abs(x(1:i)));
% Calculate spectrogram for the current signal
if i > Nspec
[S, F, T] = spectrogram(x_filtered, hamming(Nspec), overlap, Nspec, sampling_frequency, ‘yaxis’);
% Update the spectrogram
set(h_spectrogram, ‘XData’, T, ‘YData’, F, ‘CData’, 10*log10(abs(S)));
end
end
drawnow;
end
How do I band pass this signal? And is it right to rectify it after I bandpass filter it? bandpass filter, emg signal MATLAB Answers — New Questions
How to plot the electric field using when the desired signal is small and there are many data points
Problem: I have a large data set (~5gb) that consists of the following information
x – position vector
y – position vector
z – position vector
Ex – value of the electric field evaluted at (x,y,z)
Ey – value of the electric field evaluted at (x,y,z)
Ez – value of the electric field evaluted at (x,y,z)
I wish to recreate this image in matlab because the program I am using cannot handle all of the data it created:
Using
scatter(x,y, [], mag(Ez) , ‘filled’)
I get the following:
"Cropping" the data by dropping rows that are not within a specific range yields:
As you can see, the image is very fuzzy. Zooming in once more shows the problem:
What I have tried
downsample() – makes it workable, but too many points "washes out" what I need
meshgrid() does not work because I need too much memory, even if I split my vector into 300 rows and thousands of columns and loop over each column
contour() cannot get to work since the third argument (Z) is numerical data
quiver() also cannot get it to work since it wants a matrix as the thrid argumentProblem: I have a large data set (~5gb) that consists of the following information
x – position vector
y – position vector
z – position vector
Ex – value of the electric field evaluted at (x,y,z)
Ey – value of the electric field evaluted at (x,y,z)
Ez – value of the electric field evaluted at (x,y,z)
I wish to recreate this image in matlab because the program I am using cannot handle all of the data it created:
Using
scatter(x,y, [], mag(Ez) , ‘filled’)
I get the following:
"Cropping" the data by dropping rows that are not within a specific range yields:
As you can see, the image is very fuzzy. Zooming in once more shows the problem:
What I have tried
downsample() – makes it workable, but too many points "washes out" what I need
meshgrid() does not work because I need too much memory, even if I split my vector into 300 rows and thousands of columns and loop over each column
contour() cannot get to work since the third argument (Z) is numerical data
quiver() also cannot get it to work since it wants a matrix as the thrid argument Problem: I have a large data set (~5gb) that consists of the following information
x – position vector
y – position vector
z – position vector
Ex – value of the electric field evaluted at (x,y,z)
Ey – value of the electric field evaluted at (x,y,z)
Ez – value of the electric field evaluted at (x,y,z)
I wish to recreate this image in matlab because the program I am using cannot handle all of the data it created:
Using
scatter(x,y, [], mag(Ez) , ‘filled’)
I get the following:
"Cropping" the data by dropping rows that are not within a specific range yields:
As you can see, the image is very fuzzy. Zooming in once more shows the problem:
What I have tried
downsample() – makes it workable, but too many points "washes out" what I need
meshgrid() does not work because I need too much memory, even if I split my vector into 300 rows and thousands of columns and loop over each column
contour() cannot get to work since the third argument (Z) is numerical data
quiver() also cannot get it to work since it wants a matrix as the thrid argument plotting, subplot, field, image MATLAB Answers — New Questions
Correlation of 2D matrix and 3D Matrix
Hi,
I have a 3D matrix/array A and a 2D matrix/array B. I want to correlate index B(i,j) to A(i,j,k) where the element (1,1) of B is equal to element (1,1,k) of A. How do I do this?Hi,
I have a 3D matrix/array A and a 2D matrix/array B. I want to correlate index B(i,j) to A(i,j,k) where the element (1,1) of B is equal to element (1,1,k) of A. How do I do this? Hi,
I have a 3D matrix/array A and a 2D matrix/array B. I want to correlate index B(i,j) to A(i,j,k) where the element (1,1) of B is equal to element (1,1,k) of A. How do I do this? 3d array, matrix indexing MATLAB Answers — New Questions
Unable to find transfer functon using model linearizer
Hello,
I tried to find the transfer function of a system, using the Model Linearizer, by setting the input pertuberation and Output Measurement Points.
After running the model linearizer for a sinestream frequency of 10 to 10000. Using the tfest function the transfer function is estimated.
The obtained transfer function, is wrong and it highly inaccurate.
Any help would be appreciated.
Thank YouHello,
I tried to find the transfer function of a system, using the Model Linearizer, by setting the input pertuberation and Output Measurement Points.
After running the model linearizer for a sinestream frequency of 10 to 10000. Using the tfest function the transfer function is estimated.
The obtained transfer function, is wrong and it highly inaccurate.
Any help would be appreciated.
Thank You Hello,
I tried to find the transfer function of a system, using the Model Linearizer, by setting the input pertuberation and Output Measurement Points.
After running the model linearizer for a sinestream frequency of 10 to 10000. Using the tfest function the transfer function is estimated.
The obtained transfer function, is wrong and it highly inaccurate.
Any help would be appreciated.
Thank You power_electronics_control MATLAB Answers — New Questions
change the color of curve from blue to any color and make it bold
Post Content Post Content matlab MATLAB Answers — New Questions
Why I can’t plot x = years , y = GDP
Post Content Post Content plot MATLAB Answers — New Questions
How to find respective features from Principal Components
Hello Everyone!
I have a feature matrix of 4378*54. After doing PCA, I get a reduced feature matrix of 4378*29. I have used a threshold variance of 95%.
In summary, 29 principal components explain 95% of variance in my feature matrix.
How can I find the respective features in my feature matrix from the 29 principal components? Ofcourse, these 29 principal components correspond to 29 features in my feature matrix which have 54 features. How can I find those features?
I am using PCA function which gives me coeff, scores, latent and explained.
Secondly, do I have to use same PCA for both training and testing dataset? I have read in an article that I have to store the selected coeff (95% variance) from training dataset and multiply this with my testing dataset which will yield a reduced feature matrix. I have tried it and it works. But how it works, I dont understand.
Your comments will be highly appreciated.Hello Everyone!
I have a feature matrix of 4378*54. After doing PCA, I get a reduced feature matrix of 4378*29. I have used a threshold variance of 95%.
In summary, 29 principal components explain 95% of variance in my feature matrix.
How can I find the respective features in my feature matrix from the 29 principal components? Ofcourse, these 29 principal components correspond to 29 features in my feature matrix which have 54 features. How can I find those features?
I am using PCA function which gives me coeff, scores, latent and explained.
Secondly, do I have to use same PCA for both training and testing dataset? I have read in an article that I have to store the selected coeff (95% variance) from training dataset and multiply this with my testing dataset which will yield a reduced feature matrix. I have tried it and it works. But how it works, I dont understand.
Your comments will be highly appreciated. Hello Everyone!
I have a feature matrix of 4378*54. After doing PCA, I get a reduced feature matrix of 4378*29. I have used a threshold variance of 95%.
In summary, 29 principal components explain 95% of variance in my feature matrix.
How can I find the respective features in my feature matrix from the 29 principal components? Ofcourse, these 29 principal components correspond to 29 features in my feature matrix which have 54 features. How can I find those features?
I am using PCA function which gives me coeff, scores, latent and explained.
Secondly, do I have to use same PCA for both training and testing dataset? I have read in an article that I have to store the selected coeff (95% variance) from training dataset and multiply this with my testing dataset which will yield a reduced feature matrix. I have tried it and it works. But how it works, I dont understand.
Your comments will be highly appreciated. pca, features, machine learning MATLAB Answers — New Questions
De-embed S parameters for 3 Fixtures/ Pads
Hello everyone,
I am a student and have the following problem:
I would like to use the function “deembedsparams” to de-embed my DUT. Unfortunately, i am not using two fixtures or pads as intended for this function, but three. I would therefore have to de-embed all three. Can someone tell me to what extent I can use the function for my problem and what I have to consider. maybe there is a workaround solution like de-embedding each pad iteratively?
I hope someone can help me with my problem.
Many thanks in advance
PatrickHello everyone,
I am a student and have the following problem:
I would like to use the function “deembedsparams” to de-embed my DUT. Unfortunately, i am not using two fixtures or pads as intended for this function, but three. I would therefore have to de-embed all three. Can someone tell me to what extent I can use the function for my problem and what I have to consider. maybe there is a workaround solution like de-embedding each pad iteratively?
I hope someone can help me with my problem.
Many thanks in advance
Patrick Hello everyone,
I am a student and have the following problem:
I would like to use the function “deembedsparams” to de-embed my DUT. Unfortunately, i am not using two fixtures or pads as intended for this function, but three. I would therefore have to de-embed all three. Can someone tell me to what extent I can use the function for my problem and what I have to consider. maybe there is a workaround solution like de-embedding each pad iteratively?
I hope someone can help me with my problem.
Many thanks in advance
Patrick s-parameter, deembedding, deembedsparams function, sparams MATLAB Answers — New Questions