Tag Archives: matlab
How to use LQR for setpoint tracking?
Initially I was using LQR to regulate the error dynamics, i.e., I computed the gains for de = (A – BK)e, but this basically results in a PI controller since the control law (with integral action) is u = -K*e + ki*z. I have seen many sources teaching how to do it by augmenting the state vector with the integral of the error, expanding the matrices to A = [A 0; C 0], etc. but I still can’t understand how that works. I am working on a first order cruise control problem. From my observations the integral action is doing all the tracking and the -Kx term is only getting in the way, trying to regulate the state x to zero. Here is my code:
% Parameters
X_u = 0;
X_uu = 22.7841;
m = 5037.7;
% Equilibrium point x0
x0 = 20*1.852/3.6; % Longitudinal linear velocity in m/s
u0 = X_u*x0 + X_uu*x0^2 % Thrust in N
% Linearize system around x0
A = -(X_u/m + 2*X_uu/m*x0);
B = 1/m;
C = 1;
D = 0;
% System order
n = size(A,1);
% Open loop system
sys_ol = ss(A,B,C,D);
openloopPoles = eig(A)
% Augmented system with the integral of the error
A_hat = [A zeros(n,1);…
-C 0 ];
B_hat = [B; 0];
Br = [zeros(n,1); 1];
C_hat = [1 zeros(1,n)];
D_hat = 0;
% Q R matrices
Q = 1000*(C’*C);
R = 0.5e-3;
% Feedback gain
K_hat = lqr(A_hat, B_hat,Q,R)
K = K_hat(1)
ki = -K_hat(2)
% Scaling matrix
%Nbar = rscale(sys_ol,K)
% Closed loop system
AA = [A – B*K B*ki;-C 0];
BB = Br;
CC = [C 0];
DD = 0;
sys_cl = ss(AA, BB, CC, DD);
% Time vector
t = 0:0.1:30;
% Control input
u = u0*ones(size(t));
% Reference setpoint
r = 25*1.852/3.6*ones(size(t));
% Initial states
x0_hat = [x0,0]
% Simulate the response of the system
[y,t,x_hat] = lsim(sys_cl,r,t,x0_hat);
figure
plot(t, y*3.6/1.852, ‘k’, ‘LineWidth’, 1.5,’Color’,’k’)
xlabel(‘Time (seconds)’)
ylabel(‘Speed (knots)’)
title(‘Closed loop response with integrator’)
grid on
% Control effort (Thrust)
u_effort = -K*x_hat(:,1) + ki*x_hat(:,2);
figure
plot(t, u_effort,’Color’,’k’)
xlabel(‘Time (s)’)
ylabel(‘Thrust (N)’)
title(‘Control effort’)Initially I was using LQR to regulate the error dynamics, i.e., I computed the gains for de = (A – BK)e, but this basically results in a PI controller since the control law (with integral action) is u = -K*e + ki*z. I have seen many sources teaching how to do it by augmenting the state vector with the integral of the error, expanding the matrices to A = [A 0; C 0], etc. but I still can’t understand how that works. I am working on a first order cruise control problem. From my observations the integral action is doing all the tracking and the -Kx term is only getting in the way, trying to regulate the state x to zero. Here is my code:
% Parameters
X_u = 0;
X_uu = 22.7841;
m = 5037.7;
% Equilibrium point x0
x0 = 20*1.852/3.6; % Longitudinal linear velocity in m/s
u0 = X_u*x0 + X_uu*x0^2 % Thrust in N
% Linearize system around x0
A = -(X_u/m + 2*X_uu/m*x0);
B = 1/m;
C = 1;
D = 0;
% System order
n = size(A,1);
% Open loop system
sys_ol = ss(A,B,C,D);
openloopPoles = eig(A)
% Augmented system with the integral of the error
A_hat = [A zeros(n,1);…
-C 0 ];
B_hat = [B; 0];
Br = [zeros(n,1); 1];
C_hat = [1 zeros(1,n)];
D_hat = 0;
% Q R matrices
Q = 1000*(C’*C);
R = 0.5e-3;
% Feedback gain
K_hat = lqr(A_hat, B_hat,Q,R)
K = K_hat(1)
ki = -K_hat(2)
% Scaling matrix
%Nbar = rscale(sys_ol,K)
% Closed loop system
AA = [A – B*K B*ki;-C 0];
BB = Br;
CC = [C 0];
DD = 0;
sys_cl = ss(AA, BB, CC, DD);
% Time vector
t = 0:0.1:30;
% Control input
u = u0*ones(size(t));
% Reference setpoint
r = 25*1.852/3.6*ones(size(t));
% Initial states
x0_hat = [x0,0]
% Simulate the response of the system
[y,t,x_hat] = lsim(sys_cl,r,t,x0_hat);
figure
plot(t, y*3.6/1.852, ‘k’, ‘LineWidth’, 1.5,’Color’,’k’)
xlabel(‘Time (seconds)’)
ylabel(‘Speed (knots)’)
title(‘Closed loop response with integrator’)
grid on
% Control effort (Thrust)
u_effort = -K*x_hat(:,1) + ki*x_hat(:,2);
figure
plot(t, u_effort,’Color’,’k’)
xlabel(‘Time (s)’)
ylabel(‘Thrust (N)’)
title(‘Control effort’) Initially I was using LQR to regulate the error dynamics, i.e., I computed the gains for de = (A – BK)e, but this basically results in a PI controller since the control law (with integral action) is u = -K*e + ki*z. I have seen many sources teaching how to do it by augmenting the state vector with the integral of the error, expanding the matrices to A = [A 0; C 0], etc. but I still can’t understand how that works. I am working on a first order cruise control problem. From my observations the integral action is doing all the tracking and the -Kx term is only getting in the way, trying to regulate the state x to zero. Here is my code:
% Parameters
X_u = 0;
X_uu = 22.7841;
m = 5037.7;
% Equilibrium point x0
x0 = 20*1.852/3.6; % Longitudinal linear velocity in m/s
u0 = X_u*x0 + X_uu*x0^2 % Thrust in N
% Linearize system around x0
A = -(X_u/m + 2*X_uu/m*x0);
B = 1/m;
C = 1;
D = 0;
% System order
n = size(A,1);
% Open loop system
sys_ol = ss(A,B,C,D);
openloopPoles = eig(A)
% Augmented system with the integral of the error
A_hat = [A zeros(n,1);…
-C 0 ];
B_hat = [B; 0];
Br = [zeros(n,1); 1];
C_hat = [1 zeros(1,n)];
D_hat = 0;
% Q R matrices
Q = 1000*(C’*C);
R = 0.5e-3;
% Feedback gain
K_hat = lqr(A_hat, B_hat,Q,R)
K = K_hat(1)
ki = -K_hat(2)
% Scaling matrix
%Nbar = rscale(sys_ol,K)
% Closed loop system
AA = [A – B*K B*ki;-C 0];
BB = Br;
CC = [C 0];
DD = 0;
sys_cl = ss(AA, BB, CC, DD);
% Time vector
t = 0:0.1:30;
% Control input
u = u0*ones(size(t));
% Reference setpoint
r = 25*1.852/3.6*ones(size(t));
% Initial states
x0_hat = [x0,0]
% Simulate the response of the system
[y,t,x_hat] = lsim(sys_cl,r,t,x0_hat);
figure
plot(t, y*3.6/1.852, ‘k’, ‘LineWidth’, 1.5,’Color’,’k’)
xlabel(‘Time (seconds)’)
ylabel(‘Speed (knots)’)
title(‘Closed loop response with integrator’)
grid on
% Control effort (Thrust)
u_effort = -K*x_hat(:,1) + ki*x_hat(:,2);
figure
plot(t, u_effort,’Color’,’k’)
xlabel(‘Time (s)’)
ylabel(‘Thrust (N)’)
title(‘Control effort’) lqi, lqr, setpoint tracking MATLAB Answers — New Questions
Speed Up String Conversion
Hi all. I am trying to speed up string conversion of a table field as below :-
GoingUC=string(table2cell(Inps(:,5)));
Inps is a table with approximately 730000 records with 13 fields. I’ve got 6 categorical fields to convert and it is taking over 2.5 hours so I wondered if there was a quicker way to do this. I need a string array for the following code which converts the categorical strings to numbers in a map (which is quick) :-
[Unique_GoingU,~,GoingU_Numeric_Cats] = unique(GoingUC);
CTNM_GoingU=containers.Map(Unique_GoingU,num2cell(1:length(Unique_GoingU)));
NTD_GoingU=cell2mat(values(CTNM_GoingU,num2cell(GoingUC)));
It all works perfectly for my use but it’s just if I can speed it up that would be great.
Steve GrayHi all. I am trying to speed up string conversion of a table field as below :-
GoingUC=string(table2cell(Inps(:,5)));
Inps is a table with approximately 730000 records with 13 fields. I’ve got 6 categorical fields to convert and it is taking over 2.5 hours so I wondered if there was a quicker way to do this. I need a string array for the following code which converts the categorical strings to numbers in a map (which is quick) :-
[Unique_GoingU,~,GoingU_Numeric_Cats] = unique(GoingUC);
CTNM_GoingU=containers.Map(Unique_GoingU,num2cell(1:length(Unique_GoingU)));
NTD_GoingU=cell2mat(values(CTNM_GoingU,num2cell(GoingUC)));
It all works perfectly for my use but it’s just if I can speed it up that would be great.
Steve Gray Hi all. I am trying to speed up string conversion of a table field as below :-
GoingUC=string(table2cell(Inps(:,5)));
Inps is a table with approximately 730000 records with 13 fields. I’ve got 6 categorical fields to convert and it is taking over 2.5 hours so I wondered if there was a quicker way to do this. I need a string array for the following code which converts the categorical strings to numbers in a map (which is quick) :-
[Unique_GoingU,~,GoingU_Numeric_Cats] = unique(GoingUC);
CTNM_GoingU=containers.Map(Unique_GoingU,num2cell(1:length(Unique_GoingU)));
NTD_GoingU=cell2mat(values(CTNM_GoingU,num2cell(GoingUC)));
It all works perfectly for my use but it’s just if I can speed it up that would be great.
Steve Gray matlab, string, convert, speed MATLAB Answers — New Questions
How can I access the value of a string variable? I need to construct a file path from a string variable, but keep getting the variable name and not the string.
I want to construct a file path, "f" that I will use many times in a Matlab m file. From advice in an answer to someone else’s question, I am using the "fullfile" function. However, I am having what seems like a silly problem. Please see the example below.
I want to put "directory1" in the file path to get:
/Users/me/ch4/directory1/directory2/results/file_1.dat
However, when I do:
directory_name = "directory1";
f = fullfile(‘/Users/me/ch4’, directory_name, ‘directory2/results/file_1.dat’)
I get:
Error using matlab.io.ImportOptions/readtable (line 503)
Unable to find or open ‘/Users/me/ch4/directory_name/directory2/results/file_1.dat’. Check the path and filename or file permissions
How can I substitute the contents of the variable and not the variable name in the file path? Thank you for any advice.I want to construct a file path, "f" that I will use many times in a Matlab m file. From advice in an answer to someone else’s question, I am using the "fullfile" function. However, I am having what seems like a silly problem. Please see the example below.
I want to put "directory1" in the file path to get:
/Users/me/ch4/directory1/directory2/results/file_1.dat
However, when I do:
directory_name = "directory1";
f = fullfile(‘/Users/me/ch4’, directory_name, ‘directory2/results/file_1.dat’)
I get:
Error using matlab.io.ImportOptions/readtable (line 503)
Unable to find or open ‘/Users/me/ch4/directory_name/directory2/results/file_1.dat’. Check the path and filename or file permissions
How can I substitute the contents of the variable and not the variable name in the file path? Thank you for any advice. I want to construct a file path, "f" that I will use many times in a Matlab m file. From advice in an answer to someone else’s question, I am using the "fullfile" function. However, I am having what seems like a silly problem. Please see the example below.
I want to put "directory1" in the file path to get:
/Users/me/ch4/directory1/directory2/results/file_1.dat
However, when I do:
directory_name = "directory1";
f = fullfile(‘/Users/me/ch4’, directory_name, ‘directory2/results/file_1.dat’)
I get:
Error using matlab.io.ImportOptions/readtable (line 503)
Unable to find or open ‘/Users/me/ch4/directory_name/directory2/results/file_1.dat’. Check the path and filename or file permissions
How can I substitute the contents of the variable and not the variable name in the file path? Thank you for any advice. string, strings, variable, variables MATLAB Answers — New Questions
The error :undefined function getSampleTime for input arguments of type double
Matlab système bloc ‘ ‘ error occured when invoking getSampleTime methodMatlab système bloc ‘ ‘ error occured when invoking getSampleTime method Matlab système bloc ‘ ‘ error occured when invoking getSampleTime method getsampletime MATLAB Answers — New Questions
Solving a Nonlinear Equation using Newton-Raphson Method
It’s required to solve that equation:
f(x) = x.^3 – 0.165*x.^2 + 3.993*10.^-4
using Newton-Raphson Method with initial guess (x0 = 0.05) to 3 iterations and also, plot that function.
Please help me with the code (i have MATLAB R2010a) …
I want the code to be with steps and iterations and if possible calculate the error also, pleaseIt’s required to solve that equation:
f(x) = x.^3 – 0.165*x.^2 + 3.993*10.^-4
using Newton-Raphson Method with initial guess (x0 = 0.05) to 3 iterations and also, plot that function.
Please help me with the code (i have MATLAB R2010a) …
I want the code to be with steps and iterations and if possible calculate the error also, please It’s required to solve that equation:
f(x) = x.^3 – 0.165*x.^2 + 3.993*10.^-4
using Newton-Raphson Method with initial guess (x0 = 0.05) to 3 iterations and also, plot that function.
Please help me with the code (i have MATLAB R2010a) …
I want the code to be with steps and iterations and if possible calculate the error also, please newton-raphson MATLAB Answers — New Questions
Relation between flux linkage and voltage constant | power_PMSynchronousMachineParams
Hello to everyone,
I am currently working on mathematical modeling of permanent magnet synchronous motor and stuck in computing some variables from standart manufacturer specifications.
Actually, I want to understand how can I compute flux linkage from Back EMF (Ke) constant.
In Simulink, the Permanent Magnet Synchronous Machine block (Simulink Library -> Simscape/Power Systems/Specialized Technology/Fundamental Blocks/Machines), under the Advanced tab, there is a GUI which name is "Compute from standard manufacturer specifications". In this GUI, I am able to understand the math beyond the Voltage constant (ke) transformations between Vpeak/kRPM and Vrms/(rad/s). But I can’t understand how the "flux linkage established by magnets (V*s)" is calculating from this voltage constant value.
Unfortunately, there is no information in Help section of this block about this topic.
Can someone please explain this relation by mathematical derivations.
Thanks in advance.
Best Regards,
YasinHello to everyone,
I am currently working on mathematical modeling of permanent magnet synchronous motor and stuck in computing some variables from standart manufacturer specifications.
Actually, I want to understand how can I compute flux linkage from Back EMF (Ke) constant.
In Simulink, the Permanent Magnet Synchronous Machine block (Simulink Library -> Simscape/Power Systems/Specialized Technology/Fundamental Blocks/Machines), under the Advanced tab, there is a GUI which name is "Compute from standard manufacturer specifications". In this GUI, I am able to understand the math beyond the Voltage constant (ke) transformations between Vpeak/kRPM and Vrms/(rad/s). But I can’t understand how the "flux linkage established by magnets (V*s)" is calculating from this voltage constant value.
Unfortunately, there is no information in Help section of this block about this topic.
Can someone please explain this relation by mathematical derivations.
Thanks in advance.
Best Regards,
Yasin Hello to everyone,
I am currently working on mathematical modeling of permanent magnet synchronous motor and stuck in computing some variables from standart manufacturer specifications.
Actually, I want to understand how can I compute flux linkage from Back EMF (Ke) constant.
In Simulink, the Permanent Magnet Synchronous Machine block (Simulink Library -> Simscape/Power Systems/Specialized Technology/Fundamental Blocks/Machines), under the Advanced tab, there is a GUI which name is "Compute from standard manufacturer specifications". In this GUI, I am able to understand the math beyond the Voltage constant (ke) transformations between Vpeak/kRPM and Vrms/(rad/s). But I can’t understand how the "flux linkage established by magnets (V*s)" is calculating from this voltage constant value.
Unfortunately, there is no information in Help section of this block about this topic.
Can someone please explain this relation by mathematical derivations.
Thanks in advance.
Best Regards,
Yasin voltage constant, flux linkage, bemf constant, pmsm MATLAB Answers — New Questions
Attempting to account for lens distortion using ” undistortedImage = undistortImage(originalIMage, cameraParams)
I am using the MATLAB Camera Calibtion App. and am attempting to mitgate lens distortion via post processing.
% Auto-generated by cameraCalibrator app on 01-May-2024
%——————————————————-
% Define images to process
imageFileNames = {‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001 deg 2024-04-30 17-35-57.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 00015 deg w 5 deg tilt 2024-04-30 17-37-59.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000115 deg w 5 deg tilt 2024-04-30 17-38-56.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000123 deg w 5 deg tilt 2024-04-30 17-40-03.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000130 deg w 5 deg tilt 2024-04-30 17-41-40.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000138 deg w 5 deg tilt 2024-04-30 17-42-51.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 6 deg w neg 15 deg tilt 2024-04-30 17-48-28.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 13 deg w neg 15 deg tilt 2024-04-30 17-50-12.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 20 deg w neg 15 deg tilt 2024-04-30 17-51-04.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 27 deg w neg 15 deg tilt 2024-04-30 17-51-46.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 33 deg w neg 15 deg tilt 2024-04-30 17-52-37.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 39 deg w neg 15 deg tilt 2024-04-30 17-53-44.png’,…
};
% Detect checkerboards in images
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames);
imageFileNames = imageFileNames(imagesUsed);
% Read the first image to obtain image size
originalImage = imread(imageFileNames{1});
[mrows, ncols, ~] = size(originalImage);
% Generate world coordinates of the corners of the squares
squareSize = 1.270000e+01; % in units of ‘millimeters’
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
% Calibrate the camera
[cameraParams, imagesUsed, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, …
‘EstimateSkew’, true, ‘EstimateTangentialDistortion’, true, …
‘NumRadialDistortionCoefficients’, 3, ‘WorldUnits’, ‘millimeters’, …
‘InitialIntrinsicMatrix’, [], ‘InitialRadialDistortion’, [], …
‘ImageSize’, [mrows, ncols]);
% View reprojection errors
h1=figure; showReprojectionErrors(cameraParams);
% Visualize pattern locations
h2=figure; showExtrinsics(cameraParams, ‘CameraCentric’);
% Display parameter estimation errors
displayErrors(estimationErrors, cameraParams);
% For example, you can use the calibration data to remove effects of lens distortion.
undistortedImage = undistortImage(originalImage, cameraParams);
% See additional examples of how to use the calibration data. At the prompt type:
% showdemo(‘MeasuringPlanarObjectsExample’)
% showdemo(‘StructureFromMotionExample’)
JUst not sure how to get from is Highlghted code above to an answer. Is it just a subtraction of cameraParams – original image that wil tell us how to adjust for distotion in post processed maner please??I am using the MATLAB Camera Calibtion App. and am attempting to mitgate lens distortion via post processing.
% Auto-generated by cameraCalibrator app on 01-May-2024
%——————————————————-
% Define images to process
imageFileNames = {‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001 deg 2024-04-30 17-35-57.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 00015 deg w 5 deg tilt 2024-04-30 17-37-59.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000115 deg w 5 deg tilt 2024-04-30 17-38-56.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000123 deg w 5 deg tilt 2024-04-30 17-40-03.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000130 deg w 5 deg tilt 2024-04-30 17-41-40.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000138 deg w 5 deg tilt 2024-04-30 17-42-51.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 6 deg w neg 15 deg tilt 2024-04-30 17-48-28.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 13 deg w neg 15 deg tilt 2024-04-30 17-50-12.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 20 deg w neg 15 deg tilt 2024-04-30 17-51-04.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 27 deg w neg 15 deg tilt 2024-04-30 17-51-46.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 33 deg w neg 15 deg tilt 2024-04-30 17-52-37.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 39 deg w neg 15 deg tilt 2024-04-30 17-53-44.png’,…
};
% Detect checkerboards in images
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames);
imageFileNames = imageFileNames(imagesUsed);
% Read the first image to obtain image size
originalImage = imread(imageFileNames{1});
[mrows, ncols, ~] = size(originalImage);
% Generate world coordinates of the corners of the squares
squareSize = 1.270000e+01; % in units of ‘millimeters’
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
% Calibrate the camera
[cameraParams, imagesUsed, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, …
‘EstimateSkew’, true, ‘EstimateTangentialDistortion’, true, …
‘NumRadialDistortionCoefficients’, 3, ‘WorldUnits’, ‘millimeters’, …
‘InitialIntrinsicMatrix’, [], ‘InitialRadialDistortion’, [], …
‘ImageSize’, [mrows, ncols]);
% View reprojection errors
h1=figure; showReprojectionErrors(cameraParams);
% Visualize pattern locations
h2=figure; showExtrinsics(cameraParams, ‘CameraCentric’);
% Display parameter estimation errors
displayErrors(estimationErrors, cameraParams);
% For example, you can use the calibration data to remove effects of lens distortion.
undistortedImage = undistortImage(originalImage, cameraParams);
% See additional examples of how to use the calibration data. At the prompt type:
% showdemo(‘MeasuringPlanarObjectsExample’)
% showdemo(‘StructureFromMotionExample’)
JUst not sure how to get from is Highlghted code above to an answer. Is it just a subtraction of cameraParams – original image that wil tell us how to adjust for distotion in post processed maner please?? I am using the MATLAB Camera Calibtion App. and am attempting to mitgate lens distortion via post processing.
% Auto-generated by cameraCalibrator app on 01-May-2024
%——————————————————-
% Define images to process
imageFileNames = {‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001 deg 2024-04-30 17-35-57.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 00015 deg w 5 deg tilt 2024-04-30 17-37-59.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000115 deg w 5 deg tilt 2024-04-30 17-38-56.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000123 deg w 5 deg tilt 2024-04-30 17-40-03.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000130 deg w 5 deg tilt 2024-04-30 17-41-40.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 000138 deg w 5 deg tilt 2024-04-30 17-42-51.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 6 deg w neg 15 deg tilt 2024-04-30 17-48-28.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 13 deg w neg 15 deg tilt 2024-04-30 17-50-12.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 20 deg w neg 15 deg tilt 2024-04-30 17-51-04.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 27 deg w neg 15 deg tilt 2024-04-30 17-51-46.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 33 deg w neg 15 deg tilt 2024-04-30 17-52-37.png’,…
‘F:ProgramsARESIHSS ProgramPicturesLens Distortion MappingIMX323 SN 0001neg 39 deg w neg 15 deg tilt 2024-04-30 17-53-44.png’,…
};
% Detect checkerboards in images
[imagePoints, boardSize, imagesUsed] = detectCheckerboardPoints(imageFileNames);
imageFileNames = imageFileNames(imagesUsed);
% Read the first image to obtain image size
originalImage = imread(imageFileNames{1});
[mrows, ncols, ~] = size(originalImage);
% Generate world coordinates of the corners of the squares
squareSize = 1.270000e+01; % in units of ‘millimeters’
worldPoints = generateCheckerboardPoints(boardSize, squareSize);
% Calibrate the camera
[cameraParams, imagesUsed, estimationErrors] = estimateCameraParameters(imagePoints, worldPoints, …
‘EstimateSkew’, true, ‘EstimateTangentialDistortion’, true, …
‘NumRadialDistortionCoefficients’, 3, ‘WorldUnits’, ‘millimeters’, …
‘InitialIntrinsicMatrix’, [], ‘InitialRadialDistortion’, [], …
‘ImageSize’, [mrows, ncols]);
% View reprojection errors
h1=figure; showReprojectionErrors(cameraParams);
% Visualize pattern locations
h2=figure; showExtrinsics(cameraParams, ‘CameraCentric’);
% Display parameter estimation errors
displayErrors(estimationErrors, cameraParams);
% For example, you can use the calibration data to remove effects of lens distortion.
undistortedImage = undistortImage(originalImage, cameraParams);
% See additional examples of how to use the calibration data. At the prompt type:
% showdemo(‘MeasuringPlanarObjectsExample’)
% showdemo(‘StructureFromMotionExample’)
JUst not sure how to get from is Highlghted code above to an answer. Is it just a subtraction of cameraParams – original image that wil tell us how to adjust for distotion in post processed maner please?? undistortedimage MATLAB Answers — New Questions
how can I plot a P-v and T-S diagrams in simulink
Hi,
I want to make a Thermo plots like P-v and T-S based on the thermodynamic process I am modeling in simulink.
till now I have been working with the P-H diagram block but I need more details for the process.
are there any blocks for making a plot based on chosen properties? I know I can plot each parameter as time dependet by using SCOP, but that does not help me…
if the plot can be made by adding a code diractly to the main program or by using the MATLAB function block please add a manuall or a wide explanation becausse I have never done that before.
Thank YOU!!Hi,
I want to make a Thermo plots like P-v and T-S based on the thermodynamic process I am modeling in simulink.
till now I have been working with the P-H diagram block but I need more details for the process.
are there any blocks for making a plot based on chosen properties? I know I can plot each parameter as time dependet by using SCOP, but that does not help me…
if the plot can be made by adding a code diractly to the main program or by using the MATLAB function block please add a manuall or a wide explanation becausse I have never done that before.
Thank YOU!! Hi,
I want to make a Thermo plots like P-v and T-S based on the thermodynamic process I am modeling in simulink.
till now I have been working with the P-H diagram block but I need more details for the process.
are there any blocks for making a plot based on chosen properties? I know I can plot each parameter as time dependet by using SCOP, but that does not help me…
if the plot can be made by adding a code diractly to the main program or by using the MATLAB function block please add a manuall or a wide explanation becausse I have never done that before.
Thank YOU!! plotting, model, simulation MATLAB Answers — New Questions
What am I missing here? I have included all the parameters into my script but I still get zero as my answer. See script below
Consider four ponds connected by streams. Initially, the ponds were pristine.
At time t=0, after environmental accident, the second and third ponds are getting polluted with the sources, releasing pollutant substance with the following rates: f2=1 kg/h and f3=4 kg/h. Pollution spreads via the connecting streams to the other ponds, as shown in the Figure.
Formulate associated differential equations in terms of x1(t), x2(t), x3(t) and x4(t) – time functions, describing pollutant amounts in each lake. Solve problem numerically, using ode45 MATLAB procedure, and DETERMINE the amount of pollutant (in kg) in lake #2 towards the end of 48 hours of contamination. For a specific numerical example, take f12/V1=f41/V4=0.05; f23/V2=f34/V3=0.02; f24/V2=0.03 [all in 1/h].
Figure-2: Four ponds #1, #2, #3 and #4 of volumes V1, V2, V3, V4 [all in m^3], connected by streams with specific flow rates f12, f13, f23, f34, f41 [m^3/h].
Here is the script I came up with but when I run it I get zero as my anser. What am I missing?
% Define parameters
f12 = 0.05; % kg/h
f23 = 0.02; % kg/h
f24 = 0.03; % kg/h
f34 = 0.02; % kg/h
V1 = 1; % m^3
V2 = 1; % m^3
V3 = 1; % m^3
% Define time span
tspan = [0 48]; % 48 hours
% Define initial conditions
x0 = [0; 0; 0; 0]; % Initial pollutant amounts in each pond
% Define the function for the system of ODEs
ode_system = @(t, x) [
-f12/V1 * x(1);
f12/V1 * x(1) – (f23/V2 + f24/V2) * x(2);
f23/V2 * x(2) – f34/V3 * x(3);
f24/V2 * x(2) + f34/V3 * x(3);
];
% Solve the system of ODEs
[t, x] = ode45(ode_system, tspan, x0);
% Extract pollutant amount in pond 2 at the end of 48 hours
x2_end = x(end, 2);
% Display result
fprintf(‘Pollutant amount in pond 2 at the end of 48 hours: %.4f kgn’, x2_end);
% Plot results
plot(t, x);
xlabel(‘Time (hours)’);
ylabel(‘Pollutant amount (kg)’);
legend(‘Pond 1’, ‘Pond 2’, ‘Pond 3’, ‘Pond 4’);
title(‘Pollutant Amounts in Ponds Over Time’);Consider four ponds connected by streams. Initially, the ponds were pristine.
At time t=0, after environmental accident, the second and third ponds are getting polluted with the sources, releasing pollutant substance with the following rates: f2=1 kg/h and f3=4 kg/h. Pollution spreads via the connecting streams to the other ponds, as shown in the Figure.
Formulate associated differential equations in terms of x1(t), x2(t), x3(t) and x4(t) – time functions, describing pollutant amounts in each lake. Solve problem numerically, using ode45 MATLAB procedure, and DETERMINE the amount of pollutant (in kg) in lake #2 towards the end of 48 hours of contamination. For a specific numerical example, take f12/V1=f41/V4=0.05; f23/V2=f34/V3=0.02; f24/V2=0.03 [all in 1/h].
Figure-2: Four ponds #1, #2, #3 and #4 of volumes V1, V2, V3, V4 [all in m^3], connected by streams with specific flow rates f12, f13, f23, f34, f41 [m^3/h].
Here is the script I came up with but when I run it I get zero as my anser. What am I missing?
% Define parameters
f12 = 0.05; % kg/h
f23 = 0.02; % kg/h
f24 = 0.03; % kg/h
f34 = 0.02; % kg/h
V1 = 1; % m^3
V2 = 1; % m^3
V3 = 1; % m^3
% Define time span
tspan = [0 48]; % 48 hours
% Define initial conditions
x0 = [0; 0; 0; 0]; % Initial pollutant amounts in each pond
% Define the function for the system of ODEs
ode_system = @(t, x) [
-f12/V1 * x(1);
f12/V1 * x(1) – (f23/V2 + f24/V2) * x(2);
f23/V2 * x(2) – f34/V3 * x(3);
f24/V2 * x(2) + f34/V3 * x(3);
];
% Solve the system of ODEs
[t, x] = ode45(ode_system, tspan, x0);
% Extract pollutant amount in pond 2 at the end of 48 hours
x2_end = x(end, 2);
% Display result
fprintf(‘Pollutant amount in pond 2 at the end of 48 hours: %.4f kgn’, x2_end);
% Plot results
plot(t, x);
xlabel(‘Time (hours)’);
ylabel(‘Pollutant amount (kg)’);
legend(‘Pond 1’, ‘Pond 2’, ‘Pond 3’, ‘Pond 4’);
title(‘Pollutant Amounts in Ponds Over Time’); Consider four ponds connected by streams. Initially, the ponds were pristine.
At time t=0, after environmental accident, the second and third ponds are getting polluted with the sources, releasing pollutant substance with the following rates: f2=1 kg/h and f3=4 kg/h. Pollution spreads via the connecting streams to the other ponds, as shown in the Figure.
Formulate associated differential equations in terms of x1(t), x2(t), x3(t) and x4(t) – time functions, describing pollutant amounts in each lake. Solve problem numerically, using ode45 MATLAB procedure, and DETERMINE the amount of pollutant (in kg) in lake #2 towards the end of 48 hours of contamination. For a specific numerical example, take f12/V1=f41/V4=0.05; f23/V2=f34/V3=0.02; f24/V2=0.03 [all in 1/h].
Figure-2: Four ponds #1, #2, #3 and #4 of volumes V1, V2, V3, V4 [all in m^3], connected by streams with specific flow rates f12, f13, f23, f34, f41 [m^3/h].
Here is the script I came up with but when I run it I get zero as my anser. What am I missing?
% Define parameters
f12 = 0.05; % kg/h
f23 = 0.02; % kg/h
f24 = 0.03; % kg/h
f34 = 0.02; % kg/h
V1 = 1; % m^3
V2 = 1; % m^3
V3 = 1; % m^3
% Define time span
tspan = [0 48]; % 48 hours
% Define initial conditions
x0 = [0; 0; 0; 0]; % Initial pollutant amounts in each pond
% Define the function for the system of ODEs
ode_system = @(t, x) [
-f12/V1 * x(1);
f12/V1 * x(1) – (f23/V2 + f24/V2) * x(2);
f23/V2 * x(2) – f34/V3 * x(3);
f24/V2 * x(2) + f34/V3 * x(3);
];
% Solve the system of ODEs
[t, x] = ode45(ode_system, tspan, x0);
% Extract pollutant amount in pond 2 at the end of 48 hours
x2_end = x(end, 2);
% Display result
fprintf(‘Pollutant amount in pond 2 at the end of 48 hours: %.4f kgn’, x2_end);
% Plot results
plot(t, x);
xlabel(‘Time (hours)’);
ylabel(‘Pollutant amount (kg)’);
legend(‘Pond 1’, ‘Pond 2’, ‘Pond 3’, ‘Pond 4’);
title(‘Pollutant Amounts in Ponds Over Time’); 1st order ordinary differential equations MATLAB Answers — New Questions
Is it possible to subtract the baseline of a graph from the peak using the curvefitter toolbox?
Hello,
I have an image (1024×1024) which shows a laser beam (I hope it is clear in the image) and a background, and it looks like this:
What I have done so far is, choose a specific column range, and calculate the average intensity of each row, and store it in a matrix (1024×1), to plot the average intensityalong the 1024 rows like this:
I have highlighted in red, the baseline, and the unhighlighted peak depicts the laser beam.
What I want to do is, create a separate fit for the baseline (constant) and subtract it from the entire plot, to calculate the average intensity under the entire area of the peak alone. Would that be possible using the curve fitter toolbox in MATLAB? If not, are there other ways to do it?
Best regards,
Akshay.Hello,
I have an image (1024×1024) which shows a laser beam (I hope it is clear in the image) and a background, and it looks like this:
What I have done so far is, choose a specific column range, and calculate the average intensity of each row, and store it in a matrix (1024×1), to plot the average intensityalong the 1024 rows like this:
I have highlighted in red, the baseline, and the unhighlighted peak depicts the laser beam.
What I want to do is, create a separate fit for the baseline (constant) and subtract it from the entire plot, to calculate the average intensity under the entire area of the peak alone. Would that be possible using the curve fitter toolbox in MATLAB? If not, are there other ways to do it?
Best regards,
Akshay. Hello,
I have an image (1024×1024) which shows a laser beam (I hope it is clear in the image) and a background, and it looks like this:
What I have done so far is, choose a specific column range, and calculate the average intensity of each row, and store it in a matrix (1024×1), to plot the average intensityalong the 1024 rows like this:
I have highlighted in red, the baseline, and the unhighlighted peak depicts the laser beam.
What I want to do is, create a separate fit for the baseline (constant) and subtract it from the entire plot, to calculate the average intensity under the entire area of the peak alone. Would that be possible using the curve fitter toolbox in MATLAB? If not, are there other ways to do it?
Best regards,
Akshay. curve fitting, image processing MATLAB Answers — New Questions
Can not solve system of differential equations with ode45 taking into account continuity equation
I have a schematic of the following situation.
I have described the fluid velocity (c1 and c2) through the 2 pipe diameters, pressure p and volume of air in tank V, all in function of the time, with the following 5 differential equations:
where Q = c1 * S1
Note that the sum of static and dynamic pressure is the total pressure and the total pressure is equal through the whole pipe. This can be described with the following continuity equation.
There are 6 variables that change in time and therefore need to be solved with the differential equations and the continuity equation: p1L, p1R, p, c1, c2 and V.
I have made the following code.
% Functions that calculate friction losses due to pipes
zeta1 = @(c1) (0.11*(abs_rough/d1 + 68./(c1*d1/kin_visc)).^0.25)*L1/d1 * 1.1;
zeta2 = @(c2) (0.11*(abs_rough/d2 + 68./(c2*d2/kin_visc)).^0.25)*L2/d2 * 1.1;
% Continuity equation
syms p1L p1R c1 c2
convgl = p1L + rho .* c1.^2./2 == p1R + rho .* c2.^2./2;
f_equation = matlabFunction(convgl, ‘Vars’, {p1L, p1R, c1, c2});
% Define differential equations
dPdt = @(t,p) data_debiet(end)*(1-(p_v./p))/(1-(p_v/p_a)).*-p./V_0;
dCdt1 = @(t,c1,p1L) ((p_a – p1L)./rho – g*(H_1 – H_0) – (c1.^2)/2*(1+zeta_1(c1)))/L1;
dCdt2 = @(t,c2,p1R,p) ((p1R – p)./rho – g*(H_2 – H_1) – (c2.^2)/2*(1+zeta_2(c2)))/L2;
dVdt = @(t,V,c1) -c1 * S1;
% Define initial conditions
p0 = p_a;
c0 = 1e-6;
V0 = V_0;
% Solve differential equations
[t, y] = ode45(@(t, y) [dPdt(t, y(3)); dCdt1(t, y(4), y(1)); dCdt2(t, y(5), y(2), y(3)); dVdt(t, y(6), y(4))], tspan1, [p0; p0; p0; c0; c0; V0], options1);
% Extract results from y
p1L = y(:, 1);
p1R = y(:, 2);
p = y(:, 3);
c1 = y(:, 4);
c2 = y(:, 5);
V = y(:, 6);
Assume that all the other variables are known constants. I have the following error message.
Error using odearguments
@(T,Y)[DPDT(T,Y(3));DCDT1(T,Y(4),Y(1));DCDT2(T,Y(5),Y(2),Y(3));DVDT(T,Y(6),Y(4))] returns a vector of length 4, but the length of initial conditions vector is 6. The vector returned by
@(T,Y)[DPDT(T,Y(3));DCDT1(T,Y(4),Y(1));DCDT2(T,Y(5),Y(2),Y(3));DVDT(T,Y(6),Y(4))] and the initial conditions vector must have the same number of elements.
Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in Model_v4 (line 81)
[t, y] = ode45(@(t, y) [dPdt(t, y(3)); dCdt1(t, y(4), y(1)); dCdt2(t, y(5), y(2), y(3)); dVdt(t, y(6), y(4))], tspan1, [p0; p0; p0; c0; c0; V0], options1);I have a schematic of the following situation.
I have described the fluid velocity (c1 and c2) through the 2 pipe diameters, pressure p and volume of air in tank V, all in function of the time, with the following 5 differential equations:
where Q = c1 * S1
Note that the sum of static and dynamic pressure is the total pressure and the total pressure is equal through the whole pipe. This can be described with the following continuity equation.
There are 6 variables that change in time and therefore need to be solved with the differential equations and the continuity equation: p1L, p1R, p, c1, c2 and V.
I have made the following code.
% Functions that calculate friction losses due to pipes
zeta1 = @(c1) (0.11*(abs_rough/d1 + 68./(c1*d1/kin_visc)).^0.25)*L1/d1 * 1.1;
zeta2 = @(c2) (0.11*(abs_rough/d2 + 68./(c2*d2/kin_visc)).^0.25)*L2/d2 * 1.1;
% Continuity equation
syms p1L p1R c1 c2
convgl = p1L + rho .* c1.^2./2 == p1R + rho .* c2.^2./2;
f_equation = matlabFunction(convgl, ‘Vars’, {p1L, p1R, c1, c2});
% Define differential equations
dPdt = @(t,p) data_debiet(end)*(1-(p_v./p))/(1-(p_v/p_a)).*-p./V_0;
dCdt1 = @(t,c1,p1L) ((p_a – p1L)./rho – g*(H_1 – H_0) – (c1.^2)/2*(1+zeta_1(c1)))/L1;
dCdt2 = @(t,c2,p1R,p) ((p1R – p)./rho – g*(H_2 – H_1) – (c2.^2)/2*(1+zeta_2(c2)))/L2;
dVdt = @(t,V,c1) -c1 * S1;
% Define initial conditions
p0 = p_a;
c0 = 1e-6;
V0 = V_0;
% Solve differential equations
[t, y] = ode45(@(t, y) [dPdt(t, y(3)); dCdt1(t, y(4), y(1)); dCdt2(t, y(5), y(2), y(3)); dVdt(t, y(6), y(4))], tspan1, [p0; p0; p0; c0; c0; V0], options1);
% Extract results from y
p1L = y(:, 1);
p1R = y(:, 2);
p = y(:, 3);
c1 = y(:, 4);
c2 = y(:, 5);
V = y(:, 6);
Assume that all the other variables are known constants. I have the following error message.
Error using odearguments
@(T,Y)[DPDT(T,Y(3));DCDT1(T,Y(4),Y(1));DCDT2(T,Y(5),Y(2),Y(3));DVDT(T,Y(6),Y(4))] returns a vector of length 4, but the length of initial conditions vector is 6. The vector returned by
@(T,Y)[DPDT(T,Y(3));DCDT1(T,Y(4),Y(1));DCDT2(T,Y(5),Y(2),Y(3));DVDT(T,Y(6),Y(4))] and the initial conditions vector must have the same number of elements.
Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in Model_v4 (line 81)
[t, y] = ode45(@(t, y) [dPdt(t, y(3)); dCdt1(t, y(4), y(1)); dCdt2(t, y(5), y(2), y(3)); dVdt(t, y(6), y(4))], tspan1, [p0; p0; p0; c0; c0; V0], options1); I have a schematic of the following situation.
I have described the fluid velocity (c1 and c2) through the 2 pipe diameters, pressure p and volume of air in tank V, all in function of the time, with the following 5 differential equations:
where Q = c1 * S1
Note that the sum of static and dynamic pressure is the total pressure and the total pressure is equal through the whole pipe. This can be described with the following continuity equation.
There are 6 variables that change in time and therefore need to be solved with the differential equations and the continuity equation: p1L, p1R, p, c1, c2 and V.
I have made the following code.
% Functions that calculate friction losses due to pipes
zeta1 = @(c1) (0.11*(abs_rough/d1 + 68./(c1*d1/kin_visc)).^0.25)*L1/d1 * 1.1;
zeta2 = @(c2) (0.11*(abs_rough/d2 + 68./(c2*d2/kin_visc)).^0.25)*L2/d2 * 1.1;
% Continuity equation
syms p1L p1R c1 c2
convgl = p1L + rho .* c1.^2./2 == p1R + rho .* c2.^2./2;
f_equation = matlabFunction(convgl, ‘Vars’, {p1L, p1R, c1, c2});
% Define differential equations
dPdt = @(t,p) data_debiet(end)*(1-(p_v./p))/(1-(p_v/p_a)).*-p./V_0;
dCdt1 = @(t,c1,p1L) ((p_a – p1L)./rho – g*(H_1 – H_0) – (c1.^2)/2*(1+zeta_1(c1)))/L1;
dCdt2 = @(t,c2,p1R,p) ((p1R – p)./rho – g*(H_2 – H_1) – (c2.^2)/2*(1+zeta_2(c2)))/L2;
dVdt = @(t,V,c1) -c1 * S1;
% Define initial conditions
p0 = p_a;
c0 = 1e-6;
V0 = V_0;
% Solve differential equations
[t, y] = ode45(@(t, y) [dPdt(t, y(3)); dCdt1(t, y(4), y(1)); dCdt2(t, y(5), y(2), y(3)); dVdt(t, y(6), y(4))], tspan1, [p0; p0; p0; c0; c0; V0], options1);
% Extract results from y
p1L = y(:, 1);
p1R = y(:, 2);
p = y(:, 3);
c1 = y(:, 4);
c2 = y(:, 5);
V = y(:, 6);
Assume that all the other variables are known constants. I have the following error message.
Error using odearguments
@(T,Y)[DPDT(T,Y(3));DCDT1(T,Y(4),Y(1));DCDT2(T,Y(5),Y(2),Y(3));DVDT(T,Y(6),Y(4))] returns a vector of length 4, but the length of initial conditions vector is 6. The vector returned by
@(T,Y)[DPDT(T,Y(3));DCDT1(T,Y(4),Y(1));DCDT2(T,Y(5),Y(2),Y(3));DVDT(T,Y(6),Y(4))] and the initial conditions vector must have the same number of elements.
Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
Error in Model_v4 (line 81)
[t, y] = ode45(@(t, y) [dPdt(t, y(3)); dCdt1(t, y(4), y(1)); dCdt2(t, y(5), y(2), y(3)); dVdt(t, y(6), y(4))], tspan1, [p0; p0; p0; c0; c0; V0], options1); ode45, fluid dynamics MATLAB Answers — New Questions
How do I upload an excel file in matlab online
I want to upload an excel file with headers and a mixture of strings and numbers into Matlab online or Matlab drive. I am using a work computer so cant install any software on the computer.I want to upload an excel file with headers and a mixture of strings and numbers into Matlab online or Matlab drive. I am using a work computer so cant install any software on the computer. I want to upload an excel file with headers and a mixture of strings and numbers into Matlab online or Matlab drive. I am using a work computer so cant install any software on the computer. file, upload, excel MATLAB Answers — New Questions
Not able to Build FPGA BitStream for Simscape example model Half Wave Rectifier
Hello Everyone ,
I am referring to link : https://www.mathworks.com/help/hdlcoder/ug/simscape-hil-speedgoat-fpga-io-modules.html,
in which when trying to generate FPGA bitstream for ‘gmStateSpaceHDL_sschdlexHalfWaveRectifierEx/Simscape_system/HDL Subsystem’ , the simulink doesnot proceed from Section 4.2 , I have waited for around 3hrs and followed all steps mentioned in above link
Kindly help me resolve the issueHello Everyone ,
I am referring to link : https://www.mathworks.com/help/hdlcoder/ug/simscape-hil-speedgoat-fpga-io-modules.html,
in which when trying to generate FPGA bitstream for ‘gmStateSpaceHDL_sschdlexHalfWaveRectifierEx/Simscape_system/HDL Subsystem’ , the simulink doesnot proceed from Section 4.2 , I have waited for around 3hrs and followed all steps mentioned in above link
Kindly help me resolve the issue Hello Everyone ,
I am referring to link : https://www.mathworks.com/help/hdlcoder/ug/simscape-hil-speedgoat-fpga-io-modules.html,
in which when trying to generate FPGA bitstream for ‘gmStateSpaceHDL_sschdlexHalfWaveRectifierEx/Simscape_system/HDL Subsystem’ , the simulink doesnot proceed from Section 4.2 , I have waited for around 3hrs and followed all steps mentioned in above link
Kindly help me resolve the issue speedgoat hdl workflow advisor MATLAB Answers — New Questions
Not enough input arguments.
function cel=myf2c(far)
cel= (far – 32) * 5 / 9;
endfunction cel=myf2c(far)
cel= (far – 32) * 5 / 9;
end function cel=myf2c(far)
cel= (far – 32) * 5 / 9;
end help MATLAB Answers — New Questions
Three y axis with one x axis
I want to have a plot with two y axis on the left and one on the right with a common x axis for all. How can I do that?I want to have a plot with two y axis on the left and one on the right with a common x axis for all. How can I do that? I want to have a plot with two y axis on the left and one on the right with a common x axis for all. How can I do that? plot MATLAB Answers — New Questions
Failed when install Simscape Multibody Link software. matlab2023a
nstalladdon(‘smlink.r2023a.win64.zip’)
Installing smlink.r2023a.win64…
error useing installaddon
Archive architecture () does not match the MATLAB architecture (win64).
Installation of smlink.r2023a.win64 failed.nstalladdon(‘smlink.r2023a.win64.zip’)
Installing smlink.r2023a.win64…
error useing installaddon
Archive architecture () does not match the MATLAB architecture (win64).
Installation of smlink.r2023a.win64 failed. nstalladdon(‘smlink.r2023a.win64.zip’)
Installing smlink.r2023a.win64…
error useing installaddon
Archive architecture () does not match the MATLAB architecture (win64).
Installation of smlink.r2023a.win64 failed. simscape multibody link, installaddon MATLAB Answers — New Questions
Error using fmincon and integral: taking integral variable as an array while performing computation
I am minimizing q for whole range of p from 2 to 20, to find the value of d, r_g,G_g. q is function of p,d, r_g, G_g.
But while computation p is behaving as an array values varing from 2 to 20. Because of this I am getting error. How to correct this. Here my part of code
[q] = optimizeParameters();% Call optimizeParameters to define the objective function q
options = optimset(‘PlotFcns’, @optimplotfval);% Set optimization options
d0 = [-0.5, 24, 3e6];
lb = [-1, 24, 2e6];
ub = [0, 32, 6e6];
[solution,fval] = fmincon(@(x)integral(@(p)q(p,x(1),x(2),x(3)),2*pi,20*pi),d0,[],[],[],[],lb,ub,[],options); % minimize q for full range of p
function q = optimizeParameters()
% syms p d r_g G_g
%p = 2*pi;
theta = pi/4;
Vs = 250;
k = @(p)p/Vs;
c = Vs/sin(theta);
w5 = 0.001;
n = 3;
dl = -6;
d1 = @(d)dl + 2 * n * d – d;
q = @(p, d, r_g, G_g) calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
end
function answer = calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
p % printing the p here which is giving an array because of this error in further computation
% rest of the code
endI am minimizing q for whole range of p from 2 to 20, to find the value of d, r_g,G_g. q is function of p,d, r_g, G_g.
But while computation p is behaving as an array values varing from 2 to 20. Because of this I am getting error. How to correct this. Here my part of code
[q] = optimizeParameters();% Call optimizeParameters to define the objective function q
options = optimset(‘PlotFcns’, @optimplotfval);% Set optimization options
d0 = [-0.5, 24, 3e6];
lb = [-1, 24, 2e6];
ub = [0, 32, 6e6];
[solution,fval] = fmincon(@(x)integral(@(p)q(p,x(1),x(2),x(3)),2*pi,20*pi),d0,[],[],[],[],lb,ub,[],options); % minimize q for full range of p
function q = optimizeParameters()
% syms p d r_g G_g
%p = 2*pi;
theta = pi/4;
Vs = 250;
k = @(p)p/Vs;
c = Vs/sin(theta);
w5 = 0.001;
n = 3;
dl = -6;
d1 = @(d)dl + 2 * n * d – d;
q = @(p, d, r_g, G_g) calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
end
function answer = calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
p % printing the p here which is giving an array because of this error in further computation
% rest of the code
end I am minimizing q for whole range of p from 2 to 20, to find the value of d, r_g,G_g. q is function of p,d, r_g, G_g.
But while computation p is behaving as an array values varing from 2 to 20. Because of this I am getting error. How to correct this. Here my part of code
[q] = optimizeParameters();% Call optimizeParameters to define the objective function q
options = optimset(‘PlotFcns’, @optimplotfval);% Set optimization options
d0 = [-0.5, 24, 3e6];
lb = [-1, 24, 2e6];
ub = [0, 32, 6e6];
[solution,fval] = fmincon(@(x)integral(@(p)q(p,x(1),x(2),x(3)),2*pi,20*pi),d0,[],[],[],[],lb,ub,[],options); % minimize q for full range of p
function q = optimizeParameters()
% syms p d r_g G_g
%p = 2*pi;
theta = pi/4;
Vs = 250;
k = @(p)p/Vs;
c = Vs/sin(theta);
w5 = 0.001;
n = 3;
dl = -6;
d1 = @(d)dl + 2 * n * d – d;
q = @(p, d, r_g, G_g) calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
end
function answer = calculateObjective(theta, p, d, r_g, G_g, Vs, k, c, w5, n, dl, d1);
p % printing the p here which is giving an array because of this error in further computation
% rest of the code
end fmincon, integral, function, array MATLAB Answers — New Questions
Using Computational Fluid Dynamics CFD in Matlab
Hi There, I have a situation that requires Computational Fluid Dynamics to simulate a pump in a swimming pool. I have attached three scenario’s of the type of problem I need to consider. I would like to know if Matlab is able to solve this problem, and if so, which tools to use? I have extensive experience in electromagnetic simulation, but am beginning to find my way in CFD. Thanks, JohnHi There, I have a situation that requires Computational Fluid Dynamics to simulate a pump in a swimming pool. I have attached three scenario’s of the type of problem I need to consider. I would like to know if Matlab is able to solve this problem, and if so, which tools to use? I have extensive experience in electromagnetic simulation, but am beginning to find my way in CFD. Thanks, John Hi There, I have a situation that requires Computational Fluid Dynamics to simulate a pump in a swimming pool. I have attached three scenario’s of the type of problem I need to consider. I would like to know if Matlab is able to solve this problem, and if so, which tools to use? I have extensive experience in electromagnetic simulation, but am beginning to find my way in CFD. Thanks, John cfd, computational fluid dynamics MATLAB Answers — New Questions
I can’t activate MATLAB R2024a licence.
Hello,
I am using Ubuntu 22.04. I installed Matlab R2024a, but when I tried to activate the licence I got an error that the activate_matlab.sh command could not be found in the bin file. When I type the terminal matlab command
"MATLAB is selecting SOFTWARE rendering.
Licence checkout failed.
Licence Manager Error -8
Make sure the HostID of the license file matches this machine, and that the HostID on the SERVER line matches the HostID of the license file.
Troubleshoot this issue by visiting:
https://www.mathworks.com/support/lme/8
Diagnostic Information:
Feature: MATLAB
Licence path: /home/pc/.matlab/R2024a_licenses:/usr/local/MATLAB/R2024a/licenses/license.dat:/usr/local/MATLAB/R2024a/licenses/trial_12217712_R2024a.lic
Licensing error: -8,523." error. How can I solve it?Hello,
I am using Ubuntu 22.04. I installed Matlab R2024a, but when I tried to activate the licence I got an error that the activate_matlab.sh command could not be found in the bin file. When I type the terminal matlab command
"MATLAB is selecting SOFTWARE rendering.
Licence checkout failed.
Licence Manager Error -8
Make sure the HostID of the license file matches this machine, and that the HostID on the SERVER line matches the HostID of the license file.
Troubleshoot this issue by visiting:
https://www.mathworks.com/support/lme/8
Diagnostic Information:
Feature: MATLAB
Licence path: /home/pc/.matlab/R2024a_licenses:/usr/local/MATLAB/R2024a/licenses/license.dat:/usr/local/MATLAB/R2024a/licenses/trial_12217712_R2024a.lic
Licensing error: -8,523." error. How can I solve it? Hello,
I am using Ubuntu 22.04. I installed Matlab R2024a, but when I tried to activate the licence I got an error that the activate_matlab.sh command could not be found in the bin file. When I type the terminal matlab command
"MATLAB is selecting SOFTWARE rendering.
Licence checkout failed.
Licence Manager Error -8
Make sure the HostID of the license file matches this machine, and that the HostID on the SERVER line matches the HostID of the license file.
Troubleshoot this issue by visiting:
https://www.mathworks.com/support/lme/8
Diagnostic Information:
Feature: MATLAB
Licence path: /home/pc/.matlab/R2024a_licenses:/usr/local/MATLAB/R2024a/licenses/license.dat:/usr/local/MATLAB/R2024a/licenses/trial_12217712_R2024a.lic
Licensing error: -8,523." error. How can I solve it? matlab, license, error MATLAB Answers — New Questions
How to simplify one expression without Negative(-) mark
How to simplify the belowing expression B without the – mark?
I thought the result should be :
but, the result always show the MINUS sign mark.
clc;clear;
syms Z_1 Z_2 Z_3 Z_4 I_1
% (a) V_1
V_1 = I_1 * (Z_1*Z_2/(Z_1+Z_2) + Z_3*Z_4/(Z_3+Z_4));
% (b) I_Z1
I_Z1 = Z_2/(Z_1+Z_2)*I_1;
% (c) I_Z3
I_Z3 = Z_4/(Z_3+Z_4)*I_1;
% (d) I_2
I_2 = I_Z1 – I_Z3;
% (e) B
B = V_1/I_2;
% (f) D
D = I_1/I_2;
simplify(B)How to simplify the belowing expression B without the – mark?
I thought the result should be :
but, the result always show the MINUS sign mark.
clc;clear;
syms Z_1 Z_2 Z_3 Z_4 I_1
% (a) V_1
V_1 = I_1 * (Z_1*Z_2/(Z_1+Z_2) + Z_3*Z_4/(Z_3+Z_4));
% (b) I_Z1
I_Z1 = Z_2/(Z_1+Z_2)*I_1;
% (c) I_Z3
I_Z3 = Z_4/(Z_3+Z_4)*I_1;
% (d) I_2
I_2 = I_Z1 – I_Z3;
% (e) B
B = V_1/I_2;
% (f) D
D = I_1/I_2;
simplify(B) How to simplify the belowing expression B without the – mark?
I thought the result should be :
but, the result always show the MINUS sign mark.
clc;clear;
syms Z_1 Z_2 Z_3 Z_4 I_1
% (a) V_1
V_1 = I_1 * (Z_1*Z_2/(Z_1+Z_2) + Z_3*Z_4/(Z_3+Z_4));
% (b) I_Z1
I_Z1 = Z_2/(Z_1+Z_2)*I_1;
% (c) I_Z3
I_Z3 = Z_4/(Z_3+Z_4)*I_1;
% (d) I_2
I_2 = I_Z1 – I_Z3;
% (e) B
B = V_1/I_2;
% (f) D
D = I_1/I_2;
simplify(B) symbolic MATLAB Answers — New Questions