Category: Matlab
Category Archives: Matlab
how to write a function for quadratic equation
I wrote this into matlab but it doesn’t work, can someone explain why?
function [x1,x2] = QuadraticEquation (a,b,c)
d=b^2-4*a*c;
if d>=0
disp (‘two roots exist’)
x1=(-b-sqrt(d))/2*a
x2=(-b+sqrt(d))/2*a
plot(x1,0,’rx’,x2,0,’rx’)
hold on
x=-10:10
y=a*x.^2+b*x+c
plot(x,y)
hold off
else
disp (‘no real roots’)
endI wrote this into matlab but it doesn’t work, can someone explain why?
function [x1,x2] = QuadraticEquation (a,b,c)
d=b^2-4*a*c;
if d>=0
disp (‘two roots exist’)
x1=(-b-sqrt(d))/2*a
x2=(-b+sqrt(d))/2*a
plot(x1,0,’rx’,x2,0,’rx’)
hold on
x=-10:10
y=a*x.^2+b*x+c
plot(x,y)
hold off
else
disp (‘no real roots’)
end I wrote this into matlab but it doesn’t work, can someone explain why?
function [x1,x2] = QuadraticEquation (a,b,c)
d=b^2-4*a*c;
if d>=0
disp (‘two roots exist’)
x1=(-b-sqrt(d))/2*a
x2=(-b+sqrt(d))/2*a
plot(x1,0,’rx’,x2,0,’rx’)
hold on
x=-10:10
y=a*x.^2+b*x+c
plot(x,y)
hold off
else
disp (‘no real roots’)
end matlab, quadratic equation MATLAB Answers — New Questions
UPFC modelling and running of simulation
hello, i found a model regarding UPFC detailed model and i went throught the article written regarding the simulation and i refered back to the model but i do not understand the scope can someone explain them to me please.hello, i found a model regarding UPFC detailed model and i went throught the article written regarding the simulation and i refered back to the model but i do not understand the scope can someone explain them to me please. hello, i found a model regarding UPFC detailed model and i went throught the article written regarding the simulation and i refered back to the model but i do not understand the scope can someone explain them to me please. matlab, simulink, power_electronics_control MATLAB Answers — New Questions
Error using urROS2Node
Hi,
I am using MATLAB 2024a in linux, where I have installed ROS 2 and Dependencies as proposed in here by using the automated method.
As can be seen in the picture, evrething seems to work fine.
However, I am trying to connect to the UR simulator, as explained in this example using this script:
clear, clc;
ur5e = loadrobot(‘universalUR5e’);
username = ‘xxxxxx’;
password = ‘xxxxxxx’;
ROS2Folder = ‘/opt/ros/humble’;
ROS2Workspace = ‘/opt/ros/humble’; % In case of binary installation, ROS 2 Work-space is same as ROS 2 Folder
ROS2DeviceAddress = ‘192.168.56.1’;
robotAddress = ‘192.168.56.101’;
device = ros2device(ROS2DeviceAddress,username,password);
device.ROS2Folder = ROS2Folder;
device.ROS2Workspace = ROS2Workspace;
generateAndTransferLaunchScriptROS2GettingStarted(device,ROS2Workspace,robotAddress);
pause(10)
ur = urROS2Node(‘RigidBodyTree’,ur5e);
and modifying the associated function so it works on simulation:
function generateAndTransferLaunchScriptROS2GettingStarted(device,WorkSpaceFolder,RobotAddress)
% Open a file to write set of commands to launch simulated UR5e
% in URSim
fid=fopen(fullfile(tempdir,"launchUR5eROS2.sh"),"w+");
% launch depending on the installation of ros2 ur driver
if strcmp(WorkSpaceFolder, device.ROS2Folder)
% Launch command for binary installation
fprintf(fid,"gnome-terminal –title=42Simulated UR5e Robot42 — /bin/bash -c ‘source %s/setup.bash; ros2 launch ur_robot_driver ur5e.launch.py launch_rviz:=false robot_ip:=%s’",device.ROS2Folder,RobotAddress);
else
% Launch command for source installation
fprintf(fid,"gnome-terminal –title=42Simulated UR5e Robot42 — /bin/bash -c ‘source %s/setup.bash; source %s/install/setup.bash; ros2 launch ur_robot_driver ur5e.launch.py launch_rviz:=false robot_ip:=%s’",device.ROS2Folder,WorkSpaceFolder,RobotAddress);
end
fclose(fid);
% Copy file into ROS2 device
putFile(device,fullfile(tempdir,’launchUR5eROS2.sh’),’~/’)
% Make the shell script executable
system(device,’chmod a+x ~/launchUR5eROS2.sh’);
% Launch the script
% system(device,’./launchUR5eROS2HWSetup.sh &’);
system(device,’./launchUR5eROS2.sh &’); % JL: I use this instead
end
The UR sim loger viewer indicates that the communication is reached.
However, I am getting this error:
Error using ros.internal.getEmptyMessage>getMessageDataAndInfo (line 70)
How could I solve it so I can continue with the example execution?
Screenshot of the Matlab and urSim windows:Hi,
I am using MATLAB 2024a in linux, where I have installed ROS 2 and Dependencies as proposed in here by using the automated method.
As can be seen in the picture, evrething seems to work fine.
However, I am trying to connect to the UR simulator, as explained in this example using this script:
clear, clc;
ur5e = loadrobot(‘universalUR5e’);
username = ‘xxxxxx’;
password = ‘xxxxxxx’;
ROS2Folder = ‘/opt/ros/humble’;
ROS2Workspace = ‘/opt/ros/humble’; % In case of binary installation, ROS 2 Work-space is same as ROS 2 Folder
ROS2DeviceAddress = ‘192.168.56.1’;
robotAddress = ‘192.168.56.101’;
device = ros2device(ROS2DeviceAddress,username,password);
device.ROS2Folder = ROS2Folder;
device.ROS2Workspace = ROS2Workspace;
generateAndTransferLaunchScriptROS2GettingStarted(device,ROS2Workspace,robotAddress);
pause(10)
ur = urROS2Node(‘RigidBodyTree’,ur5e);
and modifying the associated function so it works on simulation:
function generateAndTransferLaunchScriptROS2GettingStarted(device,WorkSpaceFolder,RobotAddress)
% Open a file to write set of commands to launch simulated UR5e
% in URSim
fid=fopen(fullfile(tempdir,"launchUR5eROS2.sh"),"w+");
% launch depending on the installation of ros2 ur driver
if strcmp(WorkSpaceFolder, device.ROS2Folder)
% Launch command for binary installation
fprintf(fid,"gnome-terminal –title=42Simulated UR5e Robot42 — /bin/bash -c ‘source %s/setup.bash; ros2 launch ur_robot_driver ur5e.launch.py launch_rviz:=false robot_ip:=%s’",device.ROS2Folder,RobotAddress);
else
% Launch command for source installation
fprintf(fid,"gnome-terminal –title=42Simulated UR5e Robot42 — /bin/bash -c ‘source %s/setup.bash; source %s/install/setup.bash; ros2 launch ur_robot_driver ur5e.launch.py launch_rviz:=false robot_ip:=%s’",device.ROS2Folder,WorkSpaceFolder,RobotAddress);
end
fclose(fid);
% Copy file into ROS2 device
putFile(device,fullfile(tempdir,’launchUR5eROS2.sh’),’~/’)
% Make the shell script executable
system(device,’chmod a+x ~/launchUR5eROS2.sh’);
% Launch the script
% system(device,’./launchUR5eROS2HWSetup.sh &’);
system(device,’./launchUR5eROS2.sh &’); % JL: I use this instead
end
The UR sim loger viewer indicates that the communication is reached.
However, I am getting this error:
Error using ros.internal.getEmptyMessage>getMessageDataAndInfo (line 70)
How could I solve it so I can continue with the example execution?
Screenshot of the Matlab and urSim windows: Hi,
I am using MATLAB 2024a in linux, where I have installed ROS 2 and Dependencies as proposed in here by using the automated method.
As can be seen in the picture, evrething seems to work fine.
However, I am trying to connect to the UR simulator, as explained in this example using this script:
clear, clc;
ur5e = loadrobot(‘universalUR5e’);
username = ‘xxxxxx’;
password = ‘xxxxxxx’;
ROS2Folder = ‘/opt/ros/humble’;
ROS2Workspace = ‘/opt/ros/humble’; % In case of binary installation, ROS 2 Work-space is same as ROS 2 Folder
ROS2DeviceAddress = ‘192.168.56.1’;
robotAddress = ‘192.168.56.101’;
device = ros2device(ROS2DeviceAddress,username,password);
device.ROS2Folder = ROS2Folder;
device.ROS2Workspace = ROS2Workspace;
generateAndTransferLaunchScriptROS2GettingStarted(device,ROS2Workspace,robotAddress);
pause(10)
ur = urROS2Node(‘RigidBodyTree’,ur5e);
and modifying the associated function so it works on simulation:
function generateAndTransferLaunchScriptROS2GettingStarted(device,WorkSpaceFolder,RobotAddress)
% Open a file to write set of commands to launch simulated UR5e
% in URSim
fid=fopen(fullfile(tempdir,"launchUR5eROS2.sh"),"w+");
% launch depending on the installation of ros2 ur driver
if strcmp(WorkSpaceFolder, device.ROS2Folder)
% Launch command for binary installation
fprintf(fid,"gnome-terminal –title=42Simulated UR5e Robot42 — /bin/bash -c ‘source %s/setup.bash; ros2 launch ur_robot_driver ur5e.launch.py launch_rviz:=false robot_ip:=%s’",device.ROS2Folder,RobotAddress);
else
% Launch command for source installation
fprintf(fid,"gnome-terminal –title=42Simulated UR5e Robot42 — /bin/bash -c ‘source %s/setup.bash; source %s/install/setup.bash; ros2 launch ur_robot_driver ur5e.launch.py launch_rviz:=false robot_ip:=%s’",device.ROS2Folder,WorkSpaceFolder,RobotAddress);
end
fclose(fid);
% Copy file into ROS2 device
putFile(device,fullfile(tempdir,’launchUR5eROS2.sh’),’~/’)
% Make the shell script executable
system(device,’chmod a+x ~/launchUR5eROS2.sh’);
% Launch the script
% system(device,’./launchUR5eROS2HWSetup.sh &’);
system(device,’./launchUR5eROS2.sh &’); % JL: I use this instead
end
The UR sim loger viewer indicates that the communication is reached.
However, I am getting this error:
Error using ros.internal.getEmptyMessage>getMessageDataAndInfo (line 70)
How could I solve it so I can continue with the example execution?
Screenshot of the Matlab and urSim windows: urros2node, ur robot, ros2 MATLAB Answers — New Questions
Using the Black/Scholes Option Pricing Model, calculate the value of the call option given: S= 70; X=80; T=3 months; =.49; Rf =10%
Using the Black/Scholes Option Pricing Model, calculate the value of the call option given:
S= 70; X=80; T=3 months; s2=.49; Rf =10%Using the Black/Scholes Option Pricing Model, calculate the value of the call option given:
S= 70; X=80; T=3 months; s2=.49; Rf =10% Using the Black/Scholes Option Pricing Model, calculate the value of the call option given:
S= 70; X=80; T=3 months; s2=.49; Rf =10% mba MATLAB Answers — New Questions
indicating regions of flutter (F), and divergence (D)
I tried to implemented the stability boundries of a 2DOF system while my coefficents are periodic.
Initially, I wrote my homogeneous matrix and directly examined the eigenvalues, but the final plot didn’t match the reference.
clc
clear all ;
% Define parameters
I_thetaoverI_b = 2 ; % Moment of inertia pitch axis over I_b
I_psioverI_b = 2 ; % Moment of inertia yaw axis over I_b
C_thetaoverI_b = 0.00; % Damping coefficient over I_b
C_psioverI_b = 0.00; % Damping coefficient over I_b
h = 0.3; % rotor mast height
hoverR = 0.34;
R = h / hoverR;
gamma = 4; % lock number
V = 325 ; % the rotor forward velocity [knots]
Omega = V/R; % the rotor rotational speed [RPM]
freq_1_over_Omega = 1 / Omega;
%the flap moment aerodynamic coefficients for large V
M_b = -(1/10)*V;
M_u = 1/6;
%the propeller aerodynamic coefficients
H_u = V/2;
%%%%%%%%%%%the flap moment aerodynamic coefficients for small V
%M_b = -1*(1 + V^2)/8 ;
%M_u = V/4;
%the propeller aerodynamic coefficients
%H_u = (V^2/2)*log(2/V);
f_pitch= 0.01:5:140;
f_yaw= 0.01:5:140;
phi_steps = linspace(0, pi, 50); % Evaluation points from 0 to pi
divergence_map = [];
Rdivergence_map = [];
unstable = [];
for i = 1:length(f_pitch)
for j = 1:length(f_yaw)
for phi = phi_steps
% Calculate stiffness for the current frequency
w_omega_pitch = 2*pi*f_pitch(i);
w_omega_yaw = 2*pi*f_yaw(j);
K_psi = (w_omega_pitch^2) * I_psioverI_b;
K_theta = (w_omega_yaw^2) * I_thetaoverI_b;
% Define inertia matrix [M]
M_matrix = [I_thetaoverI_b + 1 + cos(2*phi), -sin(2*phi);
-sin(2*phi), I_psioverI_b + 1 – cos(2*phi)];
% Define damping matrix [D]
D11 = h^2*gamma*H_u*(1 – cos(2*phi)) – gamma*M_b*(1 + cos(2*phi)) – (2 + 2*h*gamma*M_u)*sin(2*phi);
D12 = h^2*gamma*H_u*sin(2*phi) + gamma*M_b*sin(2*phi) – 2*(1 + cos(2*phi)) – 2*h*gamma*M_u*cos(2*phi);
D21 = h^2*gamma*H_u*sin(2*phi) + gamma*M_b*sin(2*phi) + 2*(1 – cos(2*phi)) – 2*h*gamma*M_u*cos(2*phi);
D22 = h^2*gamma*H_u*(1 + cos(2*phi)) – gamma*M_b*(1 – cos(2*phi)) + (2 + 2*h*gamma*M_u)*sin(2*phi);
D_matrix = [D11, D12;
D21, D22];
% Define stiffness matrix [K]
K11 = K_theta – h*gamma*V*H_u*(1 – cos(2*phi)) + gamma*V*M_u*sin(2*phi);
K12 = -h*V*gamma*H_u*sin(2*phi) + gamma*V*M_u*(1 + cos(2*phi));
K21 = -h*gamma*V*H_u*sin(2*phi) – gamma*V*M_u*(1 – cos(2*phi));
K22 = K_psi – h*gamma*V*H_u*(1 + cos(2*phi)) – gamma*V*M_u*sin(2*phi);
K_matrix = [K11, K12;
K21, K22];
A_top = [zeros(2, 2), eye(2)];
A_bottom = [-inv(M_matrix) * K_matrix, -inv(M_matrix) * D_matrix];
A = [A_top; A_bottom];
eigenvalues = eig(A);
% Stability condition
% Flutter
if any(real(eigenvalues) > 0)
unstable = [unstable; K_psi, K_theta];
end
% Divergence condition
if det(K_matrix) < 0
divergence_map = [divergence_map; K_psi, K_theta];
end
% 1/Ω *(Divergence) proximity check
for ev = eigenvalues’
if abs(ev – freq_1_over_Omega) < 1e-2
Rdivergence_map = [Rdivergence_map; K_psi, K_theta];
end
end
end
end
end
% Plot the Flutter and divergence maps
figure;
hold on;
scatter(unstable(:,1), unstable(:,2), ‘filled’);
scatter(divergence_map(:,1), divergence_map(:,2), ‘filled’, ‘r’);
scatter(Rdivergence_map(:, 1), Rdivergence_map(:, 2), ‘filled’, ‘g’);
xlabel(‘K_psi’);
ylabel(‘K_theta’);
title(‘Whirl Flutter Diagram’);
legend(‘Flutter area’, ‘Divergence area’, ‘ 1/Ω Divergence area’);
hold off;
I’d appreciate it if you could check it. Also, if I need to use the Floquet technique, please let me know how to modify the code.I tried to implemented the stability boundries of a 2DOF system while my coefficents are periodic.
Initially, I wrote my homogeneous matrix and directly examined the eigenvalues, but the final plot didn’t match the reference.
clc
clear all ;
% Define parameters
I_thetaoverI_b = 2 ; % Moment of inertia pitch axis over I_b
I_psioverI_b = 2 ; % Moment of inertia yaw axis over I_b
C_thetaoverI_b = 0.00; % Damping coefficient over I_b
C_psioverI_b = 0.00; % Damping coefficient over I_b
h = 0.3; % rotor mast height
hoverR = 0.34;
R = h / hoverR;
gamma = 4; % lock number
V = 325 ; % the rotor forward velocity [knots]
Omega = V/R; % the rotor rotational speed [RPM]
freq_1_over_Omega = 1 / Omega;
%the flap moment aerodynamic coefficients for large V
M_b = -(1/10)*V;
M_u = 1/6;
%the propeller aerodynamic coefficients
H_u = V/2;
%%%%%%%%%%%the flap moment aerodynamic coefficients for small V
%M_b = -1*(1 + V^2)/8 ;
%M_u = V/4;
%the propeller aerodynamic coefficients
%H_u = (V^2/2)*log(2/V);
f_pitch= 0.01:5:140;
f_yaw= 0.01:5:140;
phi_steps = linspace(0, pi, 50); % Evaluation points from 0 to pi
divergence_map = [];
Rdivergence_map = [];
unstable = [];
for i = 1:length(f_pitch)
for j = 1:length(f_yaw)
for phi = phi_steps
% Calculate stiffness for the current frequency
w_omega_pitch = 2*pi*f_pitch(i);
w_omega_yaw = 2*pi*f_yaw(j);
K_psi = (w_omega_pitch^2) * I_psioverI_b;
K_theta = (w_omega_yaw^2) * I_thetaoverI_b;
% Define inertia matrix [M]
M_matrix = [I_thetaoverI_b + 1 + cos(2*phi), -sin(2*phi);
-sin(2*phi), I_psioverI_b + 1 – cos(2*phi)];
% Define damping matrix [D]
D11 = h^2*gamma*H_u*(1 – cos(2*phi)) – gamma*M_b*(1 + cos(2*phi)) – (2 + 2*h*gamma*M_u)*sin(2*phi);
D12 = h^2*gamma*H_u*sin(2*phi) + gamma*M_b*sin(2*phi) – 2*(1 + cos(2*phi)) – 2*h*gamma*M_u*cos(2*phi);
D21 = h^2*gamma*H_u*sin(2*phi) + gamma*M_b*sin(2*phi) + 2*(1 – cos(2*phi)) – 2*h*gamma*M_u*cos(2*phi);
D22 = h^2*gamma*H_u*(1 + cos(2*phi)) – gamma*M_b*(1 – cos(2*phi)) + (2 + 2*h*gamma*M_u)*sin(2*phi);
D_matrix = [D11, D12;
D21, D22];
% Define stiffness matrix [K]
K11 = K_theta – h*gamma*V*H_u*(1 – cos(2*phi)) + gamma*V*M_u*sin(2*phi);
K12 = -h*V*gamma*H_u*sin(2*phi) + gamma*V*M_u*(1 + cos(2*phi));
K21 = -h*gamma*V*H_u*sin(2*phi) – gamma*V*M_u*(1 – cos(2*phi));
K22 = K_psi – h*gamma*V*H_u*(1 + cos(2*phi)) – gamma*V*M_u*sin(2*phi);
K_matrix = [K11, K12;
K21, K22];
A_top = [zeros(2, 2), eye(2)];
A_bottom = [-inv(M_matrix) * K_matrix, -inv(M_matrix) * D_matrix];
A = [A_top; A_bottom];
eigenvalues = eig(A);
% Stability condition
% Flutter
if any(real(eigenvalues) > 0)
unstable = [unstable; K_psi, K_theta];
end
% Divergence condition
if det(K_matrix) < 0
divergence_map = [divergence_map; K_psi, K_theta];
end
% 1/Ω *(Divergence) proximity check
for ev = eigenvalues’
if abs(ev – freq_1_over_Omega) < 1e-2
Rdivergence_map = [Rdivergence_map; K_psi, K_theta];
end
end
end
end
end
% Plot the Flutter and divergence maps
figure;
hold on;
scatter(unstable(:,1), unstable(:,2), ‘filled’);
scatter(divergence_map(:,1), divergence_map(:,2), ‘filled’, ‘r’);
scatter(Rdivergence_map(:, 1), Rdivergence_map(:, 2), ‘filled’, ‘g’);
xlabel(‘K_psi’);
ylabel(‘K_theta’);
title(‘Whirl Flutter Diagram’);
legend(‘Flutter area’, ‘Divergence area’, ‘ 1/Ω Divergence area’);
hold off;
I’d appreciate it if you could check it. Also, if I need to use the Floquet technique, please let me know how to modify the code. I tried to implemented the stability boundries of a 2DOF system while my coefficents are periodic.
Initially, I wrote my homogeneous matrix and directly examined the eigenvalues, but the final plot didn’t match the reference.
clc
clear all ;
% Define parameters
I_thetaoverI_b = 2 ; % Moment of inertia pitch axis over I_b
I_psioverI_b = 2 ; % Moment of inertia yaw axis over I_b
C_thetaoverI_b = 0.00; % Damping coefficient over I_b
C_psioverI_b = 0.00; % Damping coefficient over I_b
h = 0.3; % rotor mast height
hoverR = 0.34;
R = h / hoverR;
gamma = 4; % lock number
V = 325 ; % the rotor forward velocity [knots]
Omega = V/R; % the rotor rotational speed [RPM]
freq_1_over_Omega = 1 / Omega;
%the flap moment aerodynamic coefficients for large V
M_b = -(1/10)*V;
M_u = 1/6;
%the propeller aerodynamic coefficients
H_u = V/2;
%%%%%%%%%%%the flap moment aerodynamic coefficients for small V
%M_b = -1*(1 + V^2)/8 ;
%M_u = V/4;
%the propeller aerodynamic coefficients
%H_u = (V^2/2)*log(2/V);
f_pitch= 0.01:5:140;
f_yaw= 0.01:5:140;
phi_steps = linspace(0, pi, 50); % Evaluation points from 0 to pi
divergence_map = [];
Rdivergence_map = [];
unstable = [];
for i = 1:length(f_pitch)
for j = 1:length(f_yaw)
for phi = phi_steps
% Calculate stiffness for the current frequency
w_omega_pitch = 2*pi*f_pitch(i);
w_omega_yaw = 2*pi*f_yaw(j);
K_psi = (w_omega_pitch^2) * I_psioverI_b;
K_theta = (w_omega_yaw^2) * I_thetaoverI_b;
% Define inertia matrix [M]
M_matrix = [I_thetaoverI_b + 1 + cos(2*phi), -sin(2*phi);
-sin(2*phi), I_psioverI_b + 1 – cos(2*phi)];
% Define damping matrix [D]
D11 = h^2*gamma*H_u*(1 – cos(2*phi)) – gamma*M_b*(1 + cos(2*phi)) – (2 + 2*h*gamma*M_u)*sin(2*phi);
D12 = h^2*gamma*H_u*sin(2*phi) + gamma*M_b*sin(2*phi) – 2*(1 + cos(2*phi)) – 2*h*gamma*M_u*cos(2*phi);
D21 = h^2*gamma*H_u*sin(2*phi) + gamma*M_b*sin(2*phi) + 2*(1 – cos(2*phi)) – 2*h*gamma*M_u*cos(2*phi);
D22 = h^2*gamma*H_u*(1 + cos(2*phi)) – gamma*M_b*(1 – cos(2*phi)) + (2 + 2*h*gamma*M_u)*sin(2*phi);
D_matrix = [D11, D12;
D21, D22];
% Define stiffness matrix [K]
K11 = K_theta – h*gamma*V*H_u*(1 – cos(2*phi)) + gamma*V*M_u*sin(2*phi);
K12 = -h*V*gamma*H_u*sin(2*phi) + gamma*V*M_u*(1 + cos(2*phi));
K21 = -h*gamma*V*H_u*sin(2*phi) – gamma*V*M_u*(1 – cos(2*phi));
K22 = K_psi – h*gamma*V*H_u*(1 + cos(2*phi)) – gamma*V*M_u*sin(2*phi);
K_matrix = [K11, K12;
K21, K22];
A_top = [zeros(2, 2), eye(2)];
A_bottom = [-inv(M_matrix) * K_matrix, -inv(M_matrix) * D_matrix];
A = [A_top; A_bottom];
eigenvalues = eig(A);
% Stability condition
% Flutter
if any(real(eigenvalues) > 0)
unstable = [unstable; K_psi, K_theta];
end
% Divergence condition
if det(K_matrix) < 0
divergence_map = [divergence_map; K_psi, K_theta];
end
% 1/Ω *(Divergence) proximity check
for ev = eigenvalues’
if abs(ev – freq_1_over_Omega) < 1e-2
Rdivergence_map = [Rdivergence_map; K_psi, K_theta];
end
end
end
end
end
% Plot the Flutter and divergence maps
figure;
hold on;
scatter(unstable(:,1), unstable(:,2), ‘filled’);
scatter(divergence_map(:,1), divergence_map(:,2), ‘filled’, ‘r’);
scatter(Rdivergence_map(:, 1), Rdivergence_map(:, 2), ‘filled’, ‘g’);
xlabel(‘K_psi’);
ylabel(‘K_theta’);
title(‘Whirl Flutter Diagram’);
legend(‘Flutter area’, ‘Divergence area’, ‘ 1/Ω Divergence area’);
hold off;
I’d appreciate it if you could check it. Also, if I need to use the Floquet technique, please let me know how to modify the code. aeroelastic, floquet, flutter MATLAB Answers — New Questions
Poisson CDF output is all one value
I’m creating a Poisson distribution. I then want to produce a cdf evaluated at an array of values using this distribution. However, the output of the cdf matlab function when applied to a Poisson distribution is giving me all one value. I can alter that value by changing lambda of the Poisson distribution, but it’s still all one and the same.
This is my first time using Poisson distributions in Matlab, so admittedly there is a strong possiblity there is some user error involved here, but after staring at this code and rewriting it for the last two hours I’m stumped.
The code is below, along with a plot of the evaluated cdf over an array that includes 5000 points regularly spaced from 0.00001 to 0.05. The CDF value is roughly 0.95 for all evaluated points, but it should be a nice smooth ‘S’ shape starting at 0 and climbing up as the XX value increases. Why am I getting this nonsensical output?
Computer is a Dell laptop running Windows 10.
XX = 0.00001:0.00001:0.05;
p = makedist(‘Poisson’,’lambda’,0.05);
C = cdf(p,XX);
plot(C)I’m creating a Poisson distribution. I then want to produce a cdf evaluated at an array of values using this distribution. However, the output of the cdf matlab function when applied to a Poisson distribution is giving me all one value. I can alter that value by changing lambda of the Poisson distribution, but it’s still all one and the same.
This is my first time using Poisson distributions in Matlab, so admittedly there is a strong possiblity there is some user error involved here, but after staring at this code and rewriting it for the last two hours I’m stumped.
The code is below, along with a plot of the evaluated cdf over an array that includes 5000 points regularly spaced from 0.00001 to 0.05. The CDF value is roughly 0.95 for all evaluated points, but it should be a nice smooth ‘S’ shape starting at 0 and climbing up as the XX value increases. Why am I getting this nonsensical output?
Computer is a Dell laptop running Windows 10.
XX = 0.00001:0.00001:0.05;
p = makedist(‘Poisson’,’lambda’,0.05);
C = cdf(p,XX);
plot(C) I’m creating a Poisson distribution. I then want to produce a cdf evaluated at an array of values using this distribution. However, the output of the cdf matlab function when applied to a Poisson distribution is giving me all one value. I can alter that value by changing lambda of the Poisson distribution, but it’s still all one and the same.
This is my first time using Poisson distributions in Matlab, so admittedly there is a strong possiblity there is some user error involved here, but after staring at this code and rewriting it for the last two hours I’m stumped.
The code is below, along with a plot of the evaluated cdf over an array that includes 5000 points regularly spaced from 0.00001 to 0.05. The CDF value is roughly 0.95 for all evaluated points, but it should be a nice smooth ‘S’ shape starting at 0 and climbing up as the XX value increases. Why am I getting this nonsensical output?
Computer is a Dell laptop running Windows 10.
XX = 0.00001:0.00001:0.05;
p = makedist(‘Poisson’,’lambda’,0.05);
C = cdf(p,XX);
plot(C) poisson, cdf, pdf, makedist, fitdist MATLAB Answers — New Questions
Does SoC Model Creator support only Vivado 2020.2?
I am using Vivado 2023.2 and getting an error when creating a project using SoC Model Builder.
"Vivado version 2023.1 on system path not supported. Supported tool version is 2020.2. Use the hdlsetuptoolpath function to add the appropriate synthesis tool path to your system path for the current MATLAB session."I am using Vivado 2023.2 and getting an error when creating a project using SoC Model Builder.
"Vivado version 2023.1 on system path not supported. Supported tool version is 2020.2. Use the hdlsetuptoolpath function to add the appropriate synthesis tool path to your system path for the current MATLAB session." I am using Vivado 2023.2 and getting an error when creating a project using SoC Model Builder.
"Vivado version 2023.1 on system path not supported. Supported tool version is 2020.2. Use the hdlsetuptoolpath function to add the appropriate synthesis tool path to your system path for the current MATLAB session." socmodelcreator, vivado MATLAB Answers — New Questions
the use of field graphing tools
K = 8.99e9;
% Input the number of charges
n = input(‘Enter number of charges: ‘);
% Initialize arrays to store charge values and coordinates
q = zeros(1, n);
x = zeros(1, n);
y = zeros(1, n);
minx = Inf;
maxx = -Inf;
miny = Inf;
maxy = -Inf;
% Input charge values
for i = 1:n
q(i) = input([‘Enter the charge in coulombs for charge ‘, num2str(i), ‘: ‘]);
end
% Input coordinates of the charges
for i = 1:n
x(i) = input([‘Enter x coordinate for charge ‘, num2str(i), ‘: ‘]);
y(i) = input([‘Enter y coordinate for charge ‘, num2str(i), ‘: ‘]);
if x(i) > maxx
maxx = x(i);
end
if x(i) < minx
minx = x(i);
end
if y(i) > maxy
maxy = y(i);
end
if y(i) < miny
miny = y(i);
end
end
% Define the grid for visualization
[X, Y] = meshgrid((minx-1):0.1:(maxx+1), (miny-1):0.1:(maxy+1));
Ex = zeros(size(X));
Ey = zeros(size(X));
% Calculate the electric field components
for i = 1:n
R = ((X – x(i)).^2 + (Y – y(i)).^2 ).^1.5; % Distance cubed
Ex = Ex + K * q(i) * (X – x(i)) ./ R;
Ey = Ey + K * q(i) * (Y – y(i)) ./ R;
end
% Plot the electric field vectors
figure;
quiver(X, Y, Ex, Ey);
xlabel(‘x (m)’);
ylabel(‘y (m)’);
title(‘Electric Field Vectors’);
axis equal;
grid on;
% Plot the potential distribution (if needed)
% Potential at each point
V = zeros(size(X));
for i = 1:n
R = sqrt((X – x(i)).^2 + (Y – y(i)).^2 ); % Distance
V = V + K * q(i) ./ R;
end
figure;
contourf(X, Y, V, 50, ‘LineColor’, ‘none’);
colorbar;
xlabel(‘x (m)’);
ylabel(‘y (m)’);
title(‘Potential Distribution’);
axis equal;
grid on;
i wrote the following code and i am trying to improve a couple of things
1 i want the graph to fit the boundaries so it wont draw a grid that has field lines in parts and the rest is grid
2 when i enter a negative point charge it gets problamatic this is physically correct but i want to try and write something to deal with it
3 the field lines are write but they do not really reflect the behavoir well especially when i write something like 3 + and -1 on a destince 1 from each other they look just like 1 and -1 a bit better in the voltage aspect
now this is for improvment that seem okayish yet from my trial and error i could not implement
now the problamtic request is for the next part of the code i am trying to write i am trying to draw a visullization of the field between 2 finite planes
i started this part by writing an approximation for the derivative and checking that it works
h = logspace(-1,-15,100);
real_d = -sin(1);
real_d2 = -sin(1+h);
di_d = (cos(1+h)-cos(1))./h ;
simt_d = (cos(1+h)-cos(1-h))./(2*h) ;
plot (log10(h) , log10(real_d – di_d),’*’)
hold on
plot (log10(h) , log10(real_d – simt_d),’*’)
hold o
xlabel ("log(h) from x=1")
ylabel ("log(di) from -sin(1)")
i derived the equations i need
yet i am having a hard time trying to implment them
% Constants
d = 0.5; % distance between plates in cm
R = 10.0; % radius of the plates in cm
V = 1.0; % potential difference in V
h = d / 20; % step size in cm
r_max = R + 5 * d; % maximum r value in cm
z_max = 10 * d; % maximum z value in cm
tolerance = 0.0001; % convergence criterion (0.01%)
% Define the grid
r_points = floor(r_max / h) + 1;
z_points = 2 * floor(z_max / h) + 1;
phi = zeros(r_points, z_points);
% Set boundary conditions for the finite plates
for i = 1:floor(R / h) + 1
% Positive plate at z = d/2
phi(i, floor(z_max / h) + 1 + floor(d / (2 * h))) = 0.5 * V;
% Negative plate at z = -d/2
phi(i, floor(z_max / h) + 1 – floor(d / (2 * h))) = -0.5 * V;
end
% Relaxation method
max_diff = tolerance + 1; % Initialize max difference
while max_diff > tolerance
max_diff = 0;
phi_new = phi;
for i = 2:r_points-1
for j = 2:z_points-1
% Skip the points on the plates
if (i * h <= R) && (j == floor(z_max / h) + 1 + floor(d / (2 * h)) || j == floor(z_max / h) + 1 – floor(d / (2 * h)))
continue;
end
phi_new(i, j) = 0.25 * ( …
phi(i + 1, j) * (1 + h / (2 * (i * h))) + …
phi(i – 1, j) * (1 – h / (2 * (i * h))) + …
phi(i, j + 1) + …
phi(i, j – 1));
max_diff = max(max_diff, abs(phi_new(i, j) – phi(i, j)));
end
end
phi = phi_new;
end
% Plotting the potential
r = 0:h:r_max;
z = -z_max:h:z_max;
[R, Z] = meshgrid(r, z);
figure;
contourf(R, Z, phi’, 50, ‘LineColor’, ‘none’);
colorbar;
xlabel(‘r (cm)’);
ylabel(‘z (cm)’);
title(‘Electric Potential in the r-z Plane’);
the drawing seems weird too if some one can give a bit of guidenss on the use of relaxationK = 8.99e9;
% Input the number of charges
n = input(‘Enter number of charges: ‘);
% Initialize arrays to store charge values and coordinates
q = zeros(1, n);
x = zeros(1, n);
y = zeros(1, n);
minx = Inf;
maxx = -Inf;
miny = Inf;
maxy = -Inf;
% Input charge values
for i = 1:n
q(i) = input([‘Enter the charge in coulombs for charge ‘, num2str(i), ‘: ‘]);
end
% Input coordinates of the charges
for i = 1:n
x(i) = input([‘Enter x coordinate for charge ‘, num2str(i), ‘: ‘]);
y(i) = input([‘Enter y coordinate for charge ‘, num2str(i), ‘: ‘]);
if x(i) > maxx
maxx = x(i);
end
if x(i) < minx
minx = x(i);
end
if y(i) > maxy
maxy = y(i);
end
if y(i) < miny
miny = y(i);
end
end
% Define the grid for visualization
[X, Y] = meshgrid((minx-1):0.1:(maxx+1), (miny-1):0.1:(maxy+1));
Ex = zeros(size(X));
Ey = zeros(size(X));
% Calculate the electric field components
for i = 1:n
R = ((X – x(i)).^2 + (Y – y(i)).^2 ).^1.5; % Distance cubed
Ex = Ex + K * q(i) * (X – x(i)) ./ R;
Ey = Ey + K * q(i) * (Y – y(i)) ./ R;
end
% Plot the electric field vectors
figure;
quiver(X, Y, Ex, Ey);
xlabel(‘x (m)’);
ylabel(‘y (m)’);
title(‘Electric Field Vectors’);
axis equal;
grid on;
% Plot the potential distribution (if needed)
% Potential at each point
V = zeros(size(X));
for i = 1:n
R = sqrt((X – x(i)).^2 + (Y – y(i)).^2 ); % Distance
V = V + K * q(i) ./ R;
end
figure;
contourf(X, Y, V, 50, ‘LineColor’, ‘none’);
colorbar;
xlabel(‘x (m)’);
ylabel(‘y (m)’);
title(‘Potential Distribution’);
axis equal;
grid on;
i wrote the following code and i am trying to improve a couple of things
1 i want the graph to fit the boundaries so it wont draw a grid that has field lines in parts and the rest is grid
2 when i enter a negative point charge it gets problamatic this is physically correct but i want to try and write something to deal with it
3 the field lines are write but they do not really reflect the behavoir well especially when i write something like 3 + and -1 on a destince 1 from each other they look just like 1 and -1 a bit better in the voltage aspect
now this is for improvment that seem okayish yet from my trial and error i could not implement
now the problamtic request is for the next part of the code i am trying to write i am trying to draw a visullization of the field between 2 finite planes
i started this part by writing an approximation for the derivative and checking that it works
h = logspace(-1,-15,100);
real_d = -sin(1);
real_d2 = -sin(1+h);
di_d = (cos(1+h)-cos(1))./h ;
simt_d = (cos(1+h)-cos(1-h))./(2*h) ;
plot (log10(h) , log10(real_d – di_d),’*’)
hold on
plot (log10(h) , log10(real_d – simt_d),’*’)
hold o
xlabel ("log(h) from x=1")
ylabel ("log(di) from -sin(1)")
i derived the equations i need
yet i am having a hard time trying to implment them
% Constants
d = 0.5; % distance between plates in cm
R = 10.0; % radius of the plates in cm
V = 1.0; % potential difference in V
h = d / 20; % step size in cm
r_max = R + 5 * d; % maximum r value in cm
z_max = 10 * d; % maximum z value in cm
tolerance = 0.0001; % convergence criterion (0.01%)
% Define the grid
r_points = floor(r_max / h) + 1;
z_points = 2 * floor(z_max / h) + 1;
phi = zeros(r_points, z_points);
% Set boundary conditions for the finite plates
for i = 1:floor(R / h) + 1
% Positive plate at z = d/2
phi(i, floor(z_max / h) + 1 + floor(d / (2 * h))) = 0.5 * V;
% Negative plate at z = -d/2
phi(i, floor(z_max / h) + 1 – floor(d / (2 * h))) = -0.5 * V;
end
% Relaxation method
max_diff = tolerance + 1; % Initialize max difference
while max_diff > tolerance
max_diff = 0;
phi_new = phi;
for i = 2:r_points-1
for j = 2:z_points-1
% Skip the points on the plates
if (i * h <= R) && (j == floor(z_max / h) + 1 + floor(d / (2 * h)) || j == floor(z_max / h) + 1 – floor(d / (2 * h)))
continue;
end
phi_new(i, j) = 0.25 * ( …
phi(i + 1, j) * (1 + h / (2 * (i * h))) + …
phi(i – 1, j) * (1 – h / (2 * (i * h))) + …
phi(i, j + 1) + …
phi(i, j – 1));
max_diff = max(max_diff, abs(phi_new(i, j) – phi(i, j)));
end
end
phi = phi_new;
end
% Plotting the potential
r = 0:h:r_max;
z = -z_max:h:z_max;
[R, Z] = meshgrid(r, z);
figure;
contourf(R, Z, phi’, 50, ‘LineColor’, ‘none’);
colorbar;
xlabel(‘r (cm)’);
ylabel(‘z (cm)’);
title(‘Electric Potential in the r-z Plane’);
the drawing seems weird too if some one can give a bit of guidenss on the use of relaxation K = 8.99e9;
% Input the number of charges
n = input(‘Enter number of charges: ‘);
% Initialize arrays to store charge values and coordinates
q = zeros(1, n);
x = zeros(1, n);
y = zeros(1, n);
minx = Inf;
maxx = -Inf;
miny = Inf;
maxy = -Inf;
% Input charge values
for i = 1:n
q(i) = input([‘Enter the charge in coulombs for charge ‘, num2str(i), ‘: ‘]);
end
% Input coordinates of the charges
for i = 1:n
x(i) = input([‘Enter x coordinate for charge ‘, num2str(i), ‘: ‘]);
y(i) = input([‘Enter y coordinate for charge ‘, num2str(i), ‘: ‘]);
if x(i) > maxx
maxx = x(i);
end
if x(i) < minx
minx = x(i);
end
if y(i) > maxy
maxy = y(i);
end
if y(i) < miny
miny = y(i);
end
end
% Define the grid for visualization
[X, Y] = meshgrid((minx-1):0.1:(maxx+1), (miny-1):0.1:(maxy+1));
Ex = zeros(size(X));
Ey = zeros(size(X));
% Calculate the electric field components
for i = 1:n
R = ((X – x(i)).^2 + (Y – y(i)).^2 ).^1.5; % Distance cubed
Ex = Ex + K * q(i) * (X – x(i)) ./ R;
Ey = Ey + K * q(i) * (Y – y(i)) ./ R;
end
% Plot the electric field vectors
figure;
quiver(X, Y, Ex, Ey);
xlabel(‘x (m)’);
ylabel(‘y (m)’);
title(‘Electric Field Vectors’);
axis equal;
grid on;
% Plot the potential distribution (if needed)
% Potential at each point
V = zeros(size(X));
for i = 1:n
R = sqrt((X – x(i)).^2 + (Y – y(i)).^2 ); % Distance
V = V + K * q(i) ./ R;
end
figure;
contourf(X, Y, V, 50, ‘LineColor’, ‘none’);
colorbar;
xlabel(‘x (m)’);
ylabel(‘y (m)’);
title(‘Potential Distribution’);
axis equal;
grid on;
i wrote the following code and i am trying to improve a couple of things
1 i want the graph to fit the boundaries so it wont draw a grid that has field lines in parts and the rest is grid
2 when i enter a negative point charge it gets problamatic this is physically correct but i want to try and write something to deal with it
3 the field lines are write but they do not really reflect the behavoir well especially when i write something like 3 + and -1 on a destince 1 from each other they look just like 1 and -1 a bit better in the voltage aspect
now this is for improvment that seem okayish yet from my trial and error i could not implement
now the problamtic request is for the next part of the code i am trying to write i am trying to draw a visullization of the field between 2 finite planes
i started this part by writing an approximation for the derivative and checking that it works
h = logspace(-1,-15,100);
real_d = -sin(1);
real_d2 = -sin(1+h);
di_d = (cos(1+h)-cos(1))./h ;
simt_d = (cos(1+h)-cos(1-h))./(2*h) ;
plot (log10(h) , log10(real_d – di_d),’*’)
hold on
plot (log10(h) , log10(real_d – simt_d),’*’)
hold o
xlabel ("log(h) from x=1")
ylabel ("log(di) from -sin(1)")
i derived the equations i need
yet i am having a hard time trying to implment them
% Constants
d = 0.5; % distance between plates in cm
R = 10.0; % radius of the plates in cm
V = 1.0; % potential difference in V
h = d / 20; % step size in cm
r_max = R + 5 * d; % maximum r value in cm
z_max = 10 * d; % maximum z value in cm
tolerance = 0.0001; % convergence criterion (0.01%)
% Define the grid
r_points = floor(r_max / h) + 1;
z_points = 2 * floor(z_max / h) + 1;
phi = zeros(r_points, z_points);
% Set boundary conditions for the finite plates
for i = 1:floor(R / h) + 1
% Positive plate at z = d/2
phi(i, floor(z_max / h) + 1 + floor(d / (2 * h))) = 0.5 * V;
% Negative plate at z = -d/2
phi(i, floor(z_max / h) + 1 – floor(d / (2 * h))) = -0.5 * V;
end
% Relaxation method
max_diff = tolerance + 1; % Initialize max difference
while max_diff > tolerance
max_diff = 0;
phi_new = phi;
for i = 2:r_points-1
for j = 2:z_points-1
% Skip the points on the plates
if (i * h <= R) && (j == floor(z_max / h) + 1 + floor(d / (2 * h)) || j == floor(z_max / h) + 1 – floor(d / (2 * h)))
continue;
end
phi_new(i, j) = 0.25 * ( …
phi(i + 1, j) * (1 + h / (2 * (i * h))) + …
phi(i – 1, j) * (1 – h / (2 * (i * h))) + …
phi(i, j + 1) + …
phi(i, j – 1));
max_diff = max(max_diff, abs(phi_new(i, j) – phi(i, j)));
end
end
phi = phi_new;
end
% Plotting the potential
r = 0:h:r_max;
z = -z_max:h:z_max;
[R, Z] = meshgrid(r, z);
figure;
contourf(R, Z, phi’, 50, ‘LineColor’, ‘none’);
colorbar;
xlabel(‘r (cm)’);
ylabel(‘z (cm)’);
title(‘Electric Potential in the r-z Plane’);
the drawing seems weird too if some one can give a bit of guidenss on the use of relaxation plotting MATLAB Answers — New Questions
Matlab Coder Windows -> Linux cross-compilation
Version: Matlab 2019b
Task: from Windows compile Linux static library (.a) to be used in Android application.
Current state: on Windows Matlab Coder allows generation of .lib, .dll only.
I saw there are threads for cross-compilation, does anyone made it work and can provide detailed instruction?Version: Matlab 2019b
Task: from Windows compile Linux static library (.a) to be used in Android application.
Current state: on Windows Matlab Coder allows generation of .lib, .dll only.
I saw there are threads for cross-compilation, does anyone made it work and can provide detailed instruction? Version: Matlab 2019b
Task: from Windows compile Linux static library (.a) to be used in Android application.
Current state: on Windows Matlab Coder allows generation of .lib, .dll only.
I saw there are threads for cross-compilation, does anyone made it work and can provide detailed instruction? matlab coder, cross-compilation MATLAB Answers — New Questions
Why does the error at the bottom show up even though the correct dataset seems to be selected?
It says "Unable to find suitable response variable ~"
Here is the code:
img = imread("C:UsersxxooxOneDriveデスクトップMATLAB worksDataMathWorks Imagesocean.jpg"); % Load the unlabeled image
load ("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 2gcClassifierSaturation.mat","gcClassifierSaturation") % Load the model trained using hand-selected features
load ("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 2gcClassifierBag.mat","gcClassifierBag") % Load the model trained using automatically generated features
load ("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 2bag.mat","bag") % Load bag of visual words object created by bagOfFeatures
% Step 1: Create a table of saturation-based predictor features
% Convert the image to HSV color space
hsvImg = rgb2hsv(img);
% Extract the saturation channel
saturation = hsvImg(:,:,2);
% Calculate the mean and standard deviation of the saturation
avgSat = mean(saturation(:));
stdSat = std(saturation(:));
% Create a table of saturation-based predictor features
gcTableSaturation = table(avgSat, stdSat);
% Step 2: Use gcClassifierSaturation.predictFcn to classify the unlabeled image
% Use the classifier to predict the label
prediction = gcClassifierSaturation.predictFcn(gcTableSaturation);
% Attach the prediction to the table
gcTableSaturation.prediction = prediction;
% Step 3: Create a table of bagOfFeatures-based predictor features
% Encode the image using the bag of features
featureVector = encode(bag, img);
% Create a table of predictor features for the unlabeled image
gcTableBag = array2table(featureVector);
gcTableBag.Properties.VariableNames = arrayfun(@(x) [‘f’ num2str(x)], 1:500, ‘UniformOutput’, false);
% Step 4: Use gcClassifierBag.predictFcn to classify the unlabeled image
% Use the classifier to predict the label
predictionBag = gcClassifierBag.predictFcn(gcTableBag);
% Attach the prediction to the table
gcTableBag.prediction = predictionBag;It says "Unable to find suitable response variable ~"
Here is the code:
img = imread("C:UsersxxooxOneDriveデスクトップMATLAB worksDataMathWorks Imagesocean.jpg"); % Load the unlabeled image
load ("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 2gcClassifierSaturation.mat","gcClassifierSaturation") % Load the model trained using hand-selected features
load ("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 2gcClassifierBag.mat","gcClassifierBag") % Load the model trained using automatically generated features
load ("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 2bag.mat","bag") % Load bag of visual words object created by bagOfFeatures
% Step 1: Create a table of saturation-based predictor features
% Convert the image to HSV color space
hsvImg = rgb2hsv(img);
% Extract the saturation channel
saturation = hsvImg(:,:,2);
% Calculate the mean and standard deviation of the saturation
avgSat = mean(saturation(:));
stdSat = std(saturation(:));
% Create a table of saturation-based predictor features
gcTableSaturation = table(avgSat, stdSat);
% Step 2: Use gcClassifierSaturation.predictFcn to classify the unlabeled image
% Use the classifier to predict the label
prediction = gcClassifierSaturation.predictFcn(gcTableSaturation);
% Attach the prediction to the table
gcTableSaturation.prediction = prediction;
% Step 3: Create a table of bagOfFeatures-based predictor features
% Encode the image using the bag of features
featureVector = encode(bag, img);
% Create a table of predictor features for the unlabeled image
gcTableBag = array2table(featureVector);
gcTableBag.Properties.VariableNames = arrayfun(@(x) [‘f’ num2str(x)], 1:500, ‘UniformOutput’, false);
% Step 4: Use gcClassifierBag.predictFcn to classify the unlabeled image
% Use the classifier to predict the label
predictionBag = gcClassifierBag.predictFcn(gcTableBag);
% Attach the prediction to the table
gcTableBag.prediction = predictionBag; It says "Unable to find suitable response variable ~"
Here is the code:
img = imread("C:UsersxxooxOneDriveデスクトップMATLAB worksDataMathWorks Imagesocean.jpg"); % Load the unlabeled image
load ("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 2gcClassifierSaturation.mat","gcClassifierSaturation") % Load the model trained using hand-selected features
load ("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 2gcClassifierBag.mat","gcClassifierBag") % Load the model trained using automatically generated features
load ("C:UsersxxooxOneDriveデスクトップMATLAB worksComputer Vision for Engineering and ScienceC2-MachineLearningForComputerVisionModule 2bag.mat","bag") % Load bag of visual words object created by bagOfFeatures
% Step 1: Create a table of saturation-based predictor features
% Convert the image to HSV color space
hsvImg = rgb2hsv(img);
% Extract the saturation channel
saturation = hsvImg(:,:,2);
% Calculate the mean and standard deviation of the saturation
avgSat = mean(saturation(:));
stdSat = std(saturation(:));
% Create a table of saturation-based predictor features
gcTableSaturation = table(avgSat, stdSat);
% Step 2: Use gcClassifierSaturation.predictFcn to classify the unlabeled image
% Use the classifier to predict the label
prediction = gcClassifierSaturation.predictFcn(gcTableSaturation);
% Attach the prediction to the table
gcTableSaturation.prediction = prediction;
% Step 3: Create a table of bagOfFeatures-based predictor features
% Encode the image using the bag of features
featureVector = encode(bag, img);
% Create a table of predictor features for the unlabeled image
gcTableBag = array2table(featureVector);
gcTableBag.Properties.VariableNames = arrayfun(@(x) [‘f’ num2str(x)], 1:500, ‘UniformOutput’, false);
% Step 4: Use gcClassifierBag.predictFcn to classify the unlabeled image
% Use the classifier to predict the label
predictionBag = gcClassifierBag.predictFcn(gcTableBag);
% Attach the prediction to the table
gcTableBag.prediction = predictionBag; matlab, machine learning, image classification MATLAB Answers — New Questions
Warning: Error using Simulink.SLXPart (line 74)
Hello,
recently, i keep getting this warning whenever i run or save my simulink model:
Warning: Error using Simulink.SLXPart (line 74)
Part name must start with a slash
Error in slxPackager/partDefResources>i_partinfo
Error in slxPackager/partDefResources>i_save
Error in Simulink.SLXPartHandler/pExecute (line 105)
feval(cb,packager);
Error in Simulink.SLXPartHandler/doSave (line 66)
pExecute(obj(i),packager,cb,’Save’,logger);
Error in Simulink.SLXPartHandlerRegistrar/executeSaveCallbacks (line 94)
doSave(obj.getHandlers,packager);
Error in slxPackager/executeSaveCallbacks
Error in slxPackager/save
Error in slprivate (line 11)
[varargout{1:nargout}] = feval(function_name, varargin{1:end});
Error in SimulinkStudio.callbacks.saveCB (line 14)
SLM3I.saveBlockDiagram( cbinfo.model.Handle );
Error in SLStudio.ToolBars
Please give me some tipps on how to solve this issue, thanks 🙂
BrianHello,
recently, i keep getting this warning whenever i run or save my simulink model:
Warning: Error using Simulink.SLXPart (line 74)
Part name must start with a slash
Error in slxPackager/partDefResources>i_partinfo
Error in slxPackager/partDefResources>i_save
Error in Simulink.SLXPartHandler/pExecute (line 105)
feval(cb,packager);
Error in Simulink.SLXPartHandler/doSave (line 66)
pExecute(obj(i),packager,cb,’Save’,logger);
Error in Simulink.SLXPartHandlerRegistrar/executeSaveCallbacks (line 94)
doSave(obj.getHandlers,packager);
Error in slxPackager/executeSaveCallbacks
Error in slxPackager/save
Error in slprivate (line 11)
[varargout{1:nargout}] = feval(function_name, varargin{1:end});
Error in SimulinkStudio.callbacks.saveCB (line 14)
SLM3I.saveBlockDiagram( cbinfo.model.Handle );
Error in SLStudio.ToolBars
Please give me some tipps on how to solve this issue, thanks 🙂
Brian Hello,
recently, i keep getting this warning whenever i run or save my simulink model:
Warning: Error using Simulink.SLXPart (line 74)
Part name must start with a slash
Error in slxPackager/partDefResources>i_partinfo
Error in slxPackager/partDefResources>i_save
Error in Simulink.SLXPartHandler/pExecute (line 105)
feval(cb,packager);
Error in Simulink.SLXPartHandler/doSave (line 66)
pExecute(obj(i),packager,cb,’Save’,logger);
Error in Simulink.SLXPartHandlerRegistrar/executeSaveCallbacks (line 94)
doSave(obj.getHandlers,packager);
Error in slxPackager/executeSaveCallbacks
Error in slxPackager/save
Error in slprivate (line 11)
[varargout{1:nargout}] = feval(function_name, varargin{1:end});
Error in SimulinkStudio.callbacks.saveCB (line 14)
SLM3I.saveBlockDiagram( cbinfo.model.Handle );
Error in SLStudio.ToolBars
Please give me some tipps on how to solve this issue, thanks 🙂
Brian simulink MATLAB Answers — New Questions
Pendulum using Crank-Nicolson
Hi everybody,
I’m relatively new to MatLab, and to numerical analysis in general. I have this problem I have to solve, using the Crank-Nicolson method, and I don’t have the slightest idea how to start my code…
I’m trying to solve two non-linear forced pendulum equation, which I adimensionalized as follows :
Can anyone give me a hint on how to start my process?
Thanks!
KenaHi everybody,
I’m relatively new to MatLab, and to numerical analysis in general. I have this problem I have to solve, using the Crank-Nicolson method, and I don’t have the slightest idea how to start my code…
I’m trying to solve two non-linear forced pendulum equation, which I adimensionalized as follows :
Can anyone give me a hint on how to start my process?
Thanks!
Kena Hi everybody,
I’m relatively new to MatLab, and to numerical analysis in general. I have this problem I have to solve, using the Crank-Nicolson method, and I don’t have the slightest idea how to start my code…
I’m trying to solve two non-linear forced pendulum equation, which I adimensionalized as follows :
Can anyone give me a hint on how to start my process?
Thanks!
Kena matlab, crank, nicolson, nonlinear, method MATLAB Answers — New Questions
How to plot a line on top of the continuous wavelet transform (CWT) output?
Hello. According to the attached figure, I want to add a horizontal green line (at a scale of 60) on top of the continuous wavelet transform (CWT) output. However, the line is positioned below the CWT output. Your assistance with this request would be greatly appreciated.Hello. According to the attached figure, I want to add a horizontal green line (at a scale of 60) on top of the continuous wavelet transform (CWT) output. However, the line is positioned below the CWT output. Your assistance with this request would be greatly appreciated. Hello. According to the attached figure, I want to add a horizontal green line (at a scale of 60) on top of the continuous wavelet transform (CWT) output. However, the line is positioned below the CWT output. Your assistance with this request would be greatly appreciated. plot MATLAB Answers — New Questions
problem doing implicit plotting
Hi, I am trying to make an implicit 3D plot in Matlab. A Matlab Help page says to use the following (as an example):
f = @(x,y,z) x.^2 + y.^2 – z.^2;
interval = [-5 5 -5 5 0 5];
fimplicit3(f,interval)
This works fine. But if I try to complicate things a bit by changing f to:
f = @(x,y,z) x.^2 + y.^2 – z.^2 + x.*y.
then I get the error message "Error: Invalid expression. Check for missing or extra characters".
Any idea what the problem is?
Thank you!Hi, I am trying to make an implicit 3D plot in Matlab. A Matlab Help page says to use the following (as an example):
f = @(x,y,z) x.^2 + y.^2 – z.^2;
interval = [-5 5 -5 5 0 5];
fimplicit3(f,interval)
This works fine. But if I try to complicate things a bit by changing f to:
f = @(x,y,z) x.^2 + y.^2 – z.^2 + x.*y.
then I get the error message "Error: Invalid expression. Check for missing or extra characters".
Any idea what the problem is?
Thank you! Hi, I am trying to make an implicit 3D plot in Matlab. A Matlab Help page says to use the following (as an example):
f = @(x,y,z) x.^2 + y.^2 – z.^2;
interval = [-5 5 -5 5 0 5];
fimplicit3(f,interval)
This works fine. But if I try to complicate things a bit by changing f to:
f = @(x,y,z) x.^2 + y.^2 – z.^2 + x.*y.
then I get the error message "Error: Invalid expression. Check for missing or extra characters".
Any idea what the problem is?
Thank you! plot MATLAB Answers — New Questions
My registration form in spite of following all the details was not being submitted (for the MathWorks Minidrone competition)
I’ve answered all the compulsary fields, however the form doesn’t get accepted and there is no error thrown eitherI’ve answered all the compulsary fields, however the form doesn’t get accepted and there is no error thrown either I’ve answered all the compulsary fields, however the form doesn’t get accepted and there is no error thrown either @minidronecompetition MATLAB Answers — New Questions
How can i write a code to simulate these equations
How can i write a code to simulate these equations ? These equations are related to an electric circuit .and i want to solve it in time domain.How can i write a code to simulate these equations ? These equations are related to an electric circuit .and i want to solve it in time domain. How can i write a code to simulate these equations ? These equations are related to an electric circuit .and i want to solve it in time domain. time domain MATLAB Answers — New Questions
I need to customize my chaseplot viewer in MATLAB.
Hello everyone, I need to customizing my chase plot using highway trajectories using Frenet Reference Path. In this scenario, I’m planning to implement the automatic lane change enabling/ disabling to triggering while runing the silumation. Hence, any usefule tips would be very helpful for me. Thanks in advance for your notice!Hello everyone, I need to customizing my chase plot using highway trajectories using Frenet Reference Path. In this scenario, I’m planning to implement the automatic lane change enabling/ disabling to triggering while runing the silumation. Hence, any usefule tips would be very helpful for me. Thanks in advance for your notice! Hello everyone, I need to customizing my chase plot using highway trajectories using Frenet Reference Path. In this scenario, I’m planning to implement the automatic lane change enabling/ disabling to triggering while runing the silumation. Hence, any usefule tips would be very helpful for me. Thanks in advance for your notice! simulation, matlab function MATLAB Answers — New Questions
I. For the given magnitude response, design a filter using pole-zero placement, that meets the desired response within +/- 0.5 dB. The x-axis is normalized frequency.
Post Content Post Content pole-zero placement MATLAB Answers — New Questions
Does MEX acceleration for Deep Learning need a GPU Coder license?
Does MEX acceleration for Deep Learning need a GPU Coder license?
I see the following error message:
coder.checkGpuInstall
Compatible GPU : PASSED
CUDA Environment : PASSED
Runtime : PASSED
cuFFT : PASSED
cuSOLVER : PASSED
cuBLAS : PASSED
cuDNN Environment : PASSED
Error using coder.checkGpuInstall (line 32)
Undefined variable "coder" or class "coder.gpuConfig".
"The
‘mex’
option is only available when you are using a GPU. You must also have a C/C++ compiler installed. For setup instructions, see MEX Setup (GPU Coder).
‘mex’ acceleration does not support all layers. For a list of supported layers, see Supported Layers (GPU Coder)."Does MEX acceleration for Deep Learning need a GPU Coder license?
I see the following error message:
coder.checkGpuInstall
Compatible GPU : PASSED
CUDA Environment : PASSED
Runtime : PASSED
cuFFT : PASSED
cuSOLVER : PASSED
cuBLAS : PASSED
cuDNN Environment : PASSED
Error using coder.checkGpuInstall (line 32)
Undefined variable "coder" or class "coder.gpuConfig".
"The
‘mex’
option is only available when you are using a GPU. You must also have a C/C++ compiler installed. For setup instructions, see MEX Setup (GPU Coder).
‘mex’ acceleration does not support all layers. For a list of supported layers, see Supported Layers (GPU Coder)." Does MEX acceleration for Deep Learning need a GPU Coder license?
I see the following error message:
coder.checkGpuInstall
Compatible GPU : PASSED
CUDA Environment : PASSED
Runtime : PASSED
cuFFT : PASSED
cuSOLVER : PASSED
cuBLAS : PASSED
cuDNN Environment : PASSED
Error using coder.checkGpuInstall (line 32)
Undefined variable "coder" or class "coder.gpuConfig".
"The
‘mex’
option is only available when you are using a GPU. You must also have a C/C++ compiler installed. For setup instructions, see MEX Setup (GPU Coder).
‘mex’ acceleration does not support all layers. For a list of supported layers, see Supported Layers (GPU Coder)." gpu, coder, mex, acceleration, activation, deep, learning, neural, network MATLAB Answers — New Questions
Reset Slider to zero
I want a way of setting the value of a slider to zero when it is ctrl + clicked.
Is there a way of picking up the ctrl press in the slider_changed event?I want a way of setting the value of a slider to zero when it is ctrl + clicked.
Is there a way of picking up the ctrl press in the slider_changed event? I want a way of setting the value of a slider to zero when it is ctrl + clicked.
Is there a way of picking up the ctrl press in the slider_changed event? slider, ctrl+, event MATLAB Answers — New Questions