Tag Archives: matlab
Problem with pidtune function
For the following code I keep getting just an integral element to my controller even though I am specifying PID. I need PID to get the response I’m looking for but unsure of what I’m doing wrong. tfp4 comes from a state space which I am sure is correct and isn’t causing any errors that should effect my response.
[C,info] = pidtune(tfp4, ‘PID’)
tuned = feedback(C*tfp4, 1);
t = linspace(0, 100, 1000);
u = 3*pi/180*heaviside(t);
[y42, t42] = lsim(tuned, u, t);
y42 = y42*180/pi;
figure()
plot(t42, y42)For the following code I keep getting just an integral element to my controller even though I am specifying PID. I need PID to get the response I’m looking for but unsure of what I’m doing wrong. tfp4 comes from a state space which I am sure is correct and isn’t causing any errors that should effect my response.
[C,info] = pidtune(tfp4, ‘PID’)
tuned = feedback(C*tfp4, 1);
t = linspace(0, 100, 1000);
u = 3*pi/180*heaviside(t);
[y42, t42] = lsim(tuned, u, t);
y42 = y42*180/pi;
figure()
plot(t42, y42) For the following code I keep getting just an integral element to my controller even though I am specifying PID. I need PID to get the response I’m looking for but unsure of what I’m doing wrong. tfp4 comes from a state space which I am sure is correct and isn’t causing any errors that should effect my response.
[C,info] = pidtune(tfp4, ‘PID’)
tuned = feedback(C*tfp4, 1);
t = linspace(0, 100, 1000);
u = 3*pi/180*heaviside(t);
[y42, t42] = lsim(tuned, u, t);
y42 = y42*180/pi;
figure()
plot(t42, y42) control, pid controller MATLAB Answers — New Questions
How to plot isosurface of for a wide range of values
I wish to plot isosurface of my data, But in a wide range of values. For example, MathWork has introduced the following example for one-value isosurface in its help:
[x,y,z,v] = flow;
p = patch(isosurface(x,y,z,v,-3));
isonormals(x,y,z,v,p)
p.FaceColor = ‘red’;
p.EdgeColor = ‘none’;
daspect([1 1 1])
view(3);
axis tight
camlight
lighting gouraud
The above example, will plot "flow" data if their "v" values is equal to -3.
What I want to do, is that I want to plot my data like "flow", which their "v" values are higher than -3, not exactly equal to -3.I wish to plot isosurface of my data, But in a wide range of values. For example, MathWork has introduced the following example for one-value isosurface in its help:
[x,y,z,v] = flow;
p = patch(isosurface(x,y,z,v,-3));
isonormals(x,y,z,v,p)
p.FaceColor = ‘red’;
p.EdgeColor = ‘none’;
daspect([1 1 1])
view(3);
axis tight
camlight
lighting gouraud
The above example, will plot "flow" data if their "v" values is equal to -3.
What I want to do, is that I want to plot my data like "flow", which their "v" values are higher than -3, not exactly equal to -3. I wish to plot isosurface of my data, But in a wide range of values. For example, MathWork has introduced the following example for one-value isosurface in its help:
[x,y,z,v] = flow;
p = patch(isosurface(x,y,z,v,-3));
isonormals(x,y,z,v,p)
p.FaceColor = ‘red’;
p.EdgeColor = ‘none’;
daspect([1 1 1])
view(3);
axis tight
camlight
lighting gouraud
The above example, will plot "flow" data if their "v" values is equal to -3.
What I want to do, is that I want to plot my data like "flow", which their "v" values are higher than -3, not exactly equal to -3. isosurface, 3d plots, volume plot, matlab MATLAB Answers — New Questions
Single-panel app with reflow?
The flexibility that comes with reflow is a really desirable feature. But why can’t I convert my app designer app to a single panel app with auto reflow? It would be completely adequate, and it would prevent the squishing of my layout that occurs in the current conversion method. Please, please, add this!The flexibility that comes with reflow is a really desirable feature. But why can’t I convert my app designer app to a single panel app with auto reflow? It would be completely adequate, and it would prevent the squishing of my layout that occurs in the current conversion method. Please, please, add this! The flexibility that comes with reflow is a really desirable feature. But why can’t I convert my app designer app to a single panel app with auto reflow? It would be completely adequate, and it would prevent the squishing of my layout that occurs in the current conversion method. Please, please, add this! appdesigner MATLAB Answers — New Questions
what block does simulink C2000 code generation supported?
Hi!
I have a question regarding the simulink C2000 code generation. I know some simple block such as some math operator like add, subtract, multiply, and integral are supported by the c2000 code generation. I want to know more about how many other block are also support by the code generation but I cannot find any material talk about it. I want to know is there any material can find out the answer to my question.Hi!
I have a question regarding the simulink C2000 code generation. I know some simple block such as some math operator like add, subtract, multiply, and integral are supported by the c2000 code generation. I want to know more about how many other block are also support by the code generation but I cannot find any material talk about it. I want to know is there any material can find out the answer to my question. Hi!
I have a question regarding the simulink C2000 code generation. I know some simple block such as some math operator like add, subtract, multiply, and integral are supported by the c2000 code generation. I want to know more about how many other block are also support by the code generation but I cannot find any material talk about it. I want to know is there any material can find out the answer to my question. c2000, simulink, c2000 code generation, 28379d MATLAB Answers — New Questions
Running Matlab R2024a in conjunction with Oracle JRE 8 Java ( native Apple Silicon version)
I just upgraded to Matlab R2024a and also installed Java amazon-corretto-11.jdk as part of the installation.
I am using a 3rd party software which interacts with Matlab through Java which now causes issues due to the use of Corretto. I was recommended to switch to Oracle JRE 8 to solve the problem.
Is anybody here successfully running Matlab R2024a for native Apple M1 chip in conjunction with Oracle JRE 8?
On the Oracle download ( https://www.oracle.com/au/java/technologies/downloads/ ) page there are several options for Java 8. I used the ARM64 DMG installer which then shows the following version on my mac:
1.8.0_411 (arm64) "Oracle Corporation" – "Java SE 8" /Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home
I also created a java.opts file with the following content:
-Djava.home=/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home
and stored it in /Applications/MATLAB_R2024a.app/bin/maca64/
Now Matlab R2024a is not starting up any more.
Does anybody have any recommendations?I just upgraded to Matlab R2024a and also installed Java amazon-corretto-11.jdk as part of the installation.
I am using a 3rd party software which interacts with Matlab through Java which now causes issues due to the use of Corretto. I was recommended to switch to Oracle JRE 8 to solve the problem.
Is anybody here successfully running Matlab R2024a for native Apple M1 chip in conjunction with Oracle JRE 8?
On the Oracle download ( https://www.oracle.com/au/java/technologies/downloads/ ) page there are several options for Java 8. I used the ARM64 DMG installer which then shows the following version on my mac:
1.8.0_411 (arm64) "Oracle Corporation" – "Java SE 8" /Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home
I also created a java.opts file with the following content:
-Djava.home=/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home
and stored it in /Applications/MATLAB_R2024a.app/bin/maca64/
Now Matlab R2024a is not starting up any more.
Does anybody have any recommendations? I just upgraded to Matlab R2024a and also installed Java amazon-corretto-11.jdk as part of the installation.
I am using a 3rd party software which interacts with Matlab through Java which now causes issues due to the use of Corretto. I was recommended to switch to Oracle JRE 8 to solve the problem.
Is anybody here successfully running Matlab R2024a for native Apple M1 chip in conjunction with Oracle JRE 8?
On the Oracle download ( https://www.oracle.com/au/java/technologies/downloads/ ) page there are several options for Java 8. I used the ARM64 DMG installer which then shows the following version on my mac:
1.8.0_411 (arm64) "Oracle Corporation" – "Java SE 8" /Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home
I also created a java.opts file with the following content:
-Djava.home=/Library/Java/JavaVirtualMachines/jdk-1.8.jdk/Contents/Home
and stored it in /Applications/MATLAB_R2024a.app/bin/maca64/
Now Matlab R2024a is not starting up any more.
Does anybody have any recommendations? native apple, apple m1, java, oracle jre8, matlab r2024a MATLAB Answers — New Questions
Error Using Optimization with Integer Variables and Non-linear Constraints
Hi guys! I would be very grateful if you could help me!
I’m trying to minimize the norm of a vector using optimization algorithms in MATLAB, but I’m getting an error that says "Problems with integer variables and nonlinear equality constraints are not supported."
Could someone help me understand how I can solve this and minimize the norm of the vector?
Here’s the implemented code:
wpass = 0.0318*pi;
wstop = 0.15*pi;
pb_ripple = 0.03;
sb_ripple = 0.03;
n = 25;
l = 7;
k = 2^l;
N = 15*n;
w = linspace(0,pi,N);
A = [ones(N,1) 2*cos(kron(w’,1:n))];
Ap = A((0 <= w) & (w <= wpass),:);
As = A((wstop <= w) & (w <= pi),:);
H_dac=sinc(w);
H_dac_p=H_dac(1,(0 <= w) & (w <= wpass));
H_dac_s=H_dac(1,(wstop <= w) & (w <= pi));
h = optimvar(‘h’,(n+1), ‘Type’,’integer’,’LowerBound’,-inf,’UpperBound’,inf);
norm_h=optimvar(‘norm_h’,’Type’,’integer’);
prob = optimproblem(‘ObjectiveSense’,’minimize’);
prob.Constraints.cons1 = norm_h==norm(cat(1,h(end:-1:2),h),1);
prob.Objective = norm_h;
prob.Constraints.cons2 = Ap*h <= k*(1 + pb_ripple);
prob.Constraints.cons3 = Ap*h >= k*(1 – pb_ripple);
prob.Constraints.cons4 = As*h <= k*(sb_ripple);
prob.Constraints.cons5 = As*h >= -k*(sb_ripple);
sol = solve(prob);Hi guys! I would be very grateful if you could help me!
I’m trying to minimize the norm of a vector using optimization algorithms in MATLAB, but I’m getting an error that says "Problems with integer variables and nonlinear equality constraints are not supported."
Could someone help me understand how I can solve this and minimize the norm of the vector?
Here’s the implemented code:
wpass = 0.0318*pi;
wstop = 0.15*pi;
pb_ripple = 0.03;
sb_ripple = 0.03;
n = 25;
l = 7;
k = 2^l;
N = 15*n;
w = linspace(0,pi,N);
A = [ones(N,1) 2*cos(kron(w’,1:n))];
Ap = A((0 <= w) & (w <= wpass),:);
As = A((wstop <= w) & (w <= pi),:);
H_dac=sinc(w);
H_dac_p=H_dac(1,(0 <= w) & (w <= wpass));
H_dac_s=H_dac(1,(wstop <= w) & (w <= pi));
h = optimvar(‘h’,(n+1), ‘Type’,’integer’,’LowerBound’,-inf,’UpperBound’,inf);
norm_h=optimvar(‘norm_h’,’Type’,’integer’);
prob = optimproblem(‘ObjectiveSense’,’minimize’);
prob.Constraints.cons1 = norm_h==norm(cat(1,h(end:-1:2),h),1);
prob.Objective = norm_h;
prob.Constraints.cons2 = Ap*h <= k*(1 + pb_ripple);
prob.Constraints.cons3 = Ap*h >= k*(1 – pb_ripple);
prob.Constraints.cons4 = As*h <= k*(sb_ripple);
prob.Constraints.cons5 = As*h >= -k*(sb_ripple);
sol = solve(prob); Hi guys! I would be very grateful if you could help me!
I’m trying to minimize the norm of a vector using optimization algorithms in MATLAB, but I’m getting an error that says "Problems with integer variables and nonlinear equality constraints are not supported."
Could someone help me understand how I can solve this and minimize the norm of the vector?
Here’s the implemented code:
wpass = 0.0318*pi;
wstop = 0.15*pi;
pb_ripple = 0.03;
sb_ripple = 0.03;
n = 25;
l = 7;
k = 2^l;
N = 15*n;
w = linspace(0,pi,N);
A = [ones(N,1) 2*cos(kron(w’,1:n))];
Ap = A((0 <= w) & (w <= wpass),:);
As = A((wstop <= w) & (w <= pi),:);
H_dac=sinc(w);
H_dac_p=H_dac(1,(0 <= w) & (w <= wpass));
H_dac_s=H_dac(1,(wstop <= w) & (w <= pi));
h = optimvar(‘h’,(n+1), ‘Type’,’integer’,’LowerBound’,-inf,’UpperBound’,inf);
norm_h=optimvar(‘norm_h’,’Type’,’integer’);
prob = optimproblem(‘ObjectiveSense’,’minimize’);
prob.Constraints.cons1 = norm_h==norm(cat(1,h(end:-1:2),h),1);
prob.Objective = norm_h;
prob.Constraints.cons2 = Ap*h <= k*(1 + pb_ripple);
prob.Constraints.cons3 = Ap*h >= k*(1 – pb_ripple);
prob.Constraints.cons4 = As*h <= k*(sb_ripple);
prob.Constraints.cons5 = As*h >= -k*(sb_ripple);
sol = solve(prob); optimization, minimize MATLAB Answers — New Questions
Upload custom flight controller on Pixhawk 4, and flight tests
Hello.
I developed my flight controller in simulink, and i tested it In SIL, HITL following the matlab examples https://it.mathworks.com/help/supportpkg/px4/setup-and-configuration_mw_3095a711-0234-45ed-9b75-77488e8e577d.html https://it.mathworks.com/help/supportpkg/px4/setup-and-configuration_mw_06fa168c-661f-4e54-b3b0-197c970f0ac9.htm . Now i want try to perform the flight test with my fligth controller. Now, there isn’t any examples about perform real fligth tests. So, I uploaded the firmware following the HIL procedure:
Build the firmware and upload
Default startup script
Design flight controller in simulink
Boardo Pixhawk 4, whit px4_fmu-v5_default
Then after these passages i Build Start and deploy my fligth controller into Pixhawk 4.
Now if i try to connect my drone with Qground cotnrol station, all the sensors, frame, GPS, ecc… are ok. So I armed the drone and command the take off, but the motors didn’t start to spinn. I also tried with the example in matlab "px4demo_HardwareInLoopWithSimulinkPlantStart", but even this dind’t work. A strange thing is that when i armed and command the take off, i saw (in Qg mavlink inspector) that the actuator_commands change his values to 2000 us, but the engines doesn’t move ( i use the PWM channel block). I alredy cheked that all the wires are connected, and also i tesed the engines via Qg and they works. So I guess that i miss something in the configuration for perform real fligth.
I also tried to uplod custom startup script, but i didn’t undestand very well the procedure. But in any case the default script should work, because it already disable the mc_postion_controller, and mc_attitude_controller.
I anyone have some guides to follow, or some adevices. Thanks in advance.Hello.
I developed my flight controller in simulink, and i tested it In SIL, HITL following the matlab examples https://it.mathworks.com/help/supportpkg/px4/setup-and-configuration_mw_3095a711-0234-45ed-9b75-77488e8e577d.html https://it.mathworks.com/help/supportpkg/px4/setup-and-configuration_mw_06fa168c-661f-4e54-b3b0-197c970f0ac9.htm . Now i want try to perform the flight test with my fligth controller. Now, there isn’t any examples about perform real fligth tests. So, I uploaded the firmware following the HIL procedure:
Build the firmware and upload
Default startup script
Design flight controller in simulink
Boardo Pixhawk 4, whit px4_fmu-v5_default
Then after these passages i Build Start and deploy my fligth controller into Pixhawk 4.
Now if i try to connect my drone with Qground cotnrol station, all the sensors, frame, GPS, ecc… are ok. So I armed the drone and command the take off, but the motors didn’t start to spinn. I also tried with the example in matlab "px4demo_HardwareInLoopWithSimulinkPlantStart", but even this dind’t work. A strange thing is that when i armed and command the take off, i saw (in Qg mavlink inspector) that the actuator_commands change his values to 2000 us, but the engines doesn’t move ( i use the PWM channel block). I alredy cheked that all the wires are connected, and also i tesed the engines via Qg and they works. So I guess that i miss something in the configuration for perform real fligth.
I also tried to uplod custom startup script, but i didn’t undestand very well the procedure. But in any case the default script should work, because it already disable the mc_postion_controller, and mc_attitude_controller.
I anyone have some guides to follow, or some adevices. Thanks in advance. Hello.
I developed my flight controller in simulink, and i tested it In SIL, HITL following the matlab examples https://it.mathworks.com/help/supportpkg/px4/setup-and-configuration_mw_3095a711-0234-45ed-9b75-77488e8e577d.html https://it.mathworks.com/help/supportpkg/px4/setup-and-configuration_mw_06fa168c-661f-4e54-b3b0-197c970f0ac9.htm . Now i want try to perform the flight test with my fligth controller. Now, there isn’t any examples about perform real fligth tests. So, I uploaded the firmware following the HIL procedure:
Build the firmware and upload
Default startup script
Design flight controller in simulink
Boardo Pixhawk 4, whit px4_fmu-v5_default
Then after these passages i Build Start and deploy my fligth controller into Pixhawk 4.
Now if i try to connect my drone with Qground cotnrol station, all the sensors, frame, GPS, ecc… are ok. So I armed the drone and command the take off, but the motors didn’t start to spinn. I also tried with the example in matlab "px4demo_HardwareInLoopWithSimulinkPlantStart", but even this dind’t work. A strange thing is that when i armed and command the take off, i saw (in Qg mavlink inspector) that the actuator_commands change his values to 2000 us, but the engines doesn’t move ( i use the PWM channel block). I alredy cheked that all the wires are connected, and also i tesed the engines via Qg and they works. So I guess that i miss something in the configuration for perform real fligth.
I also tried to uplod custom startup script, but i didn’t undestand very well the procedure. But in any case the default script should work, because it already disable the mc_postion_controller, and mc_attitude_controller.
I anyone have some guides to follow, or some adevices. Thanks in advance. uav toolbox support package for px4 autopilots, px4, flight tests MATLAB Answers — New Questions
GPS and IMU DATA FUSION FOR POSITION ESTIMATION
good morning, everyone.
i am working on a project to reconstruct a route using data from two sensors: gps and imu. I am working with two arduino boards, on one is integrated the imu while the gps is connected to the other board.
The sensor data is saved to two csv files which I then use in matlab.
The matlab code I have developed is as follows: I load the data from the gps and the imu and implement an extended kalman filter with the nonholonomic filter.
clear;
% carico dati del GPS
data_gps = load(‘C:UsersalberOneDriveDesktopTESIPROVE_CAMPUS14-01 (casa)output_gga.csv’);
% LATITUDINE, LONGITUDINE E ALTITUDINE
latitudine = data_gps(:,1);
longitudine = data_gps(:,2);
altitudine = data_gps(:,3);
time_gps = data_gps(:,4);
origine = [latitudine(1) longitudine(1) altitudine(1)];
%converti in coordinate locali
[xEast, yNorth, zUp] = latlon2local(latitudine, longitudine, altitudine, origine);
% converto il tempo del gps in secondi
tempi_gps_csv = num2str(time_gps);
ore = str2num(tempi_gps_csv(:,1:2));
minuti = str2num(tempi_gps_csv(:,3:4));
secondi = str2num(tempi_gps_csv(:,5:6));
tempi_secondi = ore*3600 + minuti*60 + secondi;
tempo_inizio = tempi_secondi(1);
tempi_gps = tempi_secondi – tempo_inizio;
% carico dati della IMU
data_imu = load(‘C:UsersalberOneDriveDesktopTESIPROVE_CAMPUS14-01 (casa)IMU.csv’);
N = length(data_imu);
accx_origin = data_imu(1:N,1);
accy_origin = data_imu(1:N,2);
accz_origin = data_imu(1:N,3);
acc_tot_origin = [accx_origin accy_origin accz_origin];
gyrox_origin = data_imu(1:N,4);
gyroy_origin = data_imu(1:N,5);
gyroz_origin = data_imu(1:N,6);
gyro_tot_origin = [gyrox_origin gyroy_origin gyroz_origin];
time_imu = data_imu(1:N,7);
% CONVERTO I DATI DI ACCELEROMETRO E GIROSCOPIO
% converto ‘deg/s’ to ‘rad/s’
gyro_tot_rad = convangvel(gyro_tot_origin, ‘deg/s’, ‘rad/s’);
% converto ‘g’ in ‘m/s^2’
acc_tot_meter = convacc(acc_tot_origin, ‘G”s’, ‘m/s^2’);
%converto il tempo della imu in secondi
tempi_imu_csv = num2str(floor(time_imu));
ore = str2num(tempi_imu_csv(:,1:2));
minuti = str2num(tempi_imu_csv(:,3:4));
secondi = str2num(tempi_imu_csv(:,5:6));
tempi_imu = ore*3600 + minuti*60 + secondi + mod(time_imu,1);
tempi_imu = tempi_imu – tempo_inizio;
% vettore tempi per l’operazione di interpolazione
tempo_desiderato = (tempi_imu(1):0.01:tempi_imu(end))’;
% ——— INTERPOLAZIONE ———–
accx = interp1(tempi_imu, acc_tot_meter(:,1), tempo_desiderato); %la time_imu sarebbe il ‘utc.delta_millis’ che calcolo
accy = interp1(tempi_imu, acc_tot_meter(:,2), tempo_desiderato);
accz = interp1(tempi_imu, acc_tot_meter(:,3), tempo_desiderato);
acc_tot = [accx accy accz];
% gyrox = interp1(time_imu, gyrox_origin, tempo_desiderato);
% gyroy = interp1(time_imu, gyroy_origin, tempo_desiderato);
% gyroz = interp1(time_imu, gyroz_origin, tempo_desiderato);
gyrox = interp1(tempi_imu, gyro_tot_rad(:,1), tempo_desiderato);
gyroy = interp1(tempi_imu, gyro_tot_rad(:,2), tempo_desiderato);
gyroz = interp1(tempi_imu, gyro_tot_rad(:,3), tempo_desiderato);
gyro_tot = [gyrox gyroy gyroz];
% vado ad interpolare anche le coord del gps
lat_interp = interp1(tempi_gps, latitudine, tempo_desiderato);
lon_interp = interp1(tempi_gps, longitudine, tempo_desiderato);
alt_interp = interp1(tempi_gps, altitudine, tempo_desiderato);
length_imu = length(acc_tot); %numero di elementi sul file csv
length_gps = length(data_gps);
% —————— IMU FILTER ———————–
fuse = imufilter(‘ReferenceFrame’, ‘NED’,’SampleRate’, 100,’GyroscopeNoise’, 0.0597, ‘AccelerometerNoise’, 3.8416e-04);
[orientazione ,angVelBodyRecovered] = fuse(acc_tot, gyro_tot);
% Plot Euler angles in degrees
A = eulerd(orientazione, ‘ZYX’, ‘frame’);
plot(eulerd(orientazione, ‘ZYX’, ‘frame’));
title(‘Orientation Estimate’);
legend(‘Z-rotation’, ‘Y-rotation’, ‘X-rotation’);
ylabel(‘Degrees’);
% ————— QUA C’E’ LA PARTE PER IL FILTRO ———————–
imuFs_nonHolonomic = 100;
imuFs_imuFilter = 100;
gpsFs = 1;
imuSamplesPerGPS = imuFs_nonHolonomic/gpsFs;
localOrigin = [latitudine(1) longitudine(1) altitudine(1)];
% ——————- DEFINIZIONE NONHOLONOMIC FILTER ———————
filt = insfilterNonholonomic(‘ReferenceFrame’, ‘NED’);
filt.IMUSampleRate = imuFs_nonHolonomic;
filt.ReferenceLocation = localOrigin;
filt.StateCovariance = 1e-6*eye(16);
% parametri del filtro: noise acc e gyro
filt.AccelerometerNoise = 3.8416e-04;
filt.GyroscopeNoise = 0.0597;
Rpos = 0.001 * eye(3);
% ——- LOOP PRINCIPALE PER IL FILTRO ——————-
numIMUSamples = length(tempo_desiderato);
estOrient = quaternion.ones(numIMUSamples,1);
estPos = zeros(numIMUSamples,3);
estVel = zeros(numIMUSamples,3);
gpsIdx = 1;
correzioni = [];
factor_div = round(numIMUSamples/length_gps);
for idx = 1:numIMUSamples
predict(filt, acc_tot(idx,:), gyro_tot(idx,:)); %Predict filter state
tcorrente = tempo_desiderato(idx);
if tempi_gps(gpsIdx+1)<=tcorrente
% if (mod(idx, factor_div) == 0) %Correct filter state….. fai il fuseGPS ogni 1000 campioni (se simulo su 2 minuti)…
%gpsLLA(gpsIdx,:) = [latitudine(gpsIdx,:) longitudine(gpsIdx,:) altitudine(gpsIdx,:)];
%interp1 per gps su tempocorr
prima = pose(filt);
% fusegps(filt, [lat_interp(gpsIdx,:) lon_interp(gpsIdx,:) altitudine(gpsIdx,:)], Rpos);
fusegps(filt, [latitudine(gpsIdx,:) longitudine(gpsIdx,:) altitudine(gpsIdx,:)], Rpos);
dopo = pose(filt);
correzioni = [correzioni; prima, dopo]; %memorizza correzioni GPS
%[estPos(gpsIdx,:), estOrient(gpsIdx,:), estVel(gpsIdx,:)] = pose(filt); %Log estimated pose
gpsIdx = gpsIdx + 1;
end
[estPos(idx,:), estOrient(idx,:), estVel(gpsIdx,:)] = pose(filt);
end
% plot del risultato
plot(xEast,yNorth,’k’);
xlabel(‘x [m]’);
ylabel(‘y [m]’);
hold on
plot(estPos(:,2), estPos(:,1), ‘g’);
The final plot result should be different from what I get, can anyone tell me why?
I can also share the csv files if needed.
Thank you very much,
alberto.good morning, everyone.
i am working on a project to reconstruct a route using data from two sensors: gps and imu. I am working with two arduino boards, on one is integrated the imu while the gps is connected to the other board.
The sensor data is saved to two csv files which I then use in matlab.
The matlab code I have developed is as follows: I load the data from the gps and the imu and implement an extended kalman filter with the nonholonomic filter.
clear;
% carico dati del GPS
data_gps = load(‘C:UsersalberOneDriveDesktopTESIPROVE_CAMPUS14-01 (casa)output_gga.csv’);
% LATITUDINE, LONGITUDINE E ALTITUDINE
latitudine = data_gps(:,1);
longitudine = data_gps(:,2);
altitudine = data_gps(:,3);
time_gps = data_gps(:,4);
origine = [latitudine(1) longitudine(1) altitudine(1)];
%converti in coordinate locali
[xEast, yNorth, zUp] = latlon2local(latitudine, longitudine, altitudine, origine);
% converto il tempo del gps in secondi
tempi_gps_csv = num2str(time_gps);
ore = str2num(tempi_gps_csv(:,1:2));
minuti = str2num(tempi_gps_csv(:,3:4));
secondi = str2num(tempi_gps_csv(:,5:6));
tempi_secondi = ore*3600 + minuti*60 + secondi;
tempo_inizio = tempi_secondi(1);
tempi_gps = tempi_secondi – tempo_inizio;
% carico dati della IMU
data_imu = load(‘C:UsersalberOneDriveDesktopTESIPROVE_CAMPUS14-01 (casa)IMU.csv’);
N = length(data_imu);
accx_origin = data_imu(1:N,1);
accy_origin = data_imu(1:N,2);
accz_origin = data_imu(1:N,3);
acc_tot_origin = [accx_origin accy_origin accz_origin];
gyrox_origin = data_imu(1:N,4);
gyroy_origin = data_imu(1:N,5);
gyroz_origin = data_imu(1:N,6);
gyro_tot_origin = [gyrox_origin gyroy_origin gyroz_origin];
time_imu = data_imu(1:N,7);
% CONVERTO I DATI DI ACCELEROMETRO E GIROSCOPIO
% converto ‘deg/s’ to ‘rad/s’
gyro_tot_rad = convangvel(gyro_tot_origin, ‘deg/s’, ‘rad/s’);
% converto ‘g’ in ‘m/s^2’
acc_tot_meter = convacc(acc_tot_origin, ‘G”s’, ‘m/s^2’);
%converto il tempo della imu in secondi
tempi_imu_csv = num2str(floor(time_imu));
ore = str2num(tempi_imu_csv(:,1:2));
minuti = str2num(tempi_imu_csv(:,3:4));
secondi = str2num(tempi_imu_csv(:,5:6));
tempi_imu = ore*3600 + minuti*60 + secondi + mod(time_imu,1);
tempi_imu = tempi_imu – tempo_inizio;
% vettore tempi per l’operazione di interpolazione
tempo_desiderato = (tempi_imu(1):0.01:tempi_imu(end))’;
% ——— INTERPOLAZIONE ———–
accx = interp1(tempi_imu, acc_tot_meter(:,1), tempo_desiderato); %la time_imu sarebbe il ‘utc.delta_millis’ che calcolo
accy = interp1(tempi_imu, acc_tot_meter(:,2), tempo_desiderato);
accz = interp1(tempi_imu, acc_tot_meter(:,3), tempo_desiderato);
acc_tot = [accx accy accz];
% gyrox = interp1(time_imu, gyrox_origin, tempo_desiderato);
% gyroy = interp1(time_imu, gyroy_origin, tempo_desiderato);
% gyroz = interp1(time_imu, gyroz_origin, tempo_desiderato);
gyrox = interp1(tempi_imu, gyro_tot_rad(:,1), tempo_desiderato);
gyroy = interp1(tempi_imu, gyro_tot_rad(:,2), tempo_desiderato);
gyroz = interp1(tempi_imu, gyro_tot_rad(:,3), tempo_desiderato);
gyro_tot = [gyrox gyroy gyroz];
% vado ad interpolare anche le coord del gps
lat_interp = interp1(tempi_gps, latitudine, tempo_desiderato);
lon_interp = interp1(tempi_gps, longitudine, tempo_desiderato);
alt_interp = interp1(tempi_gps, altitudine, tempo_desiderato);
length_imu = length(acc_tot); %numero di elementi sul file csv
length_gps = length(data_gps);
% —————— IMU FILTER ———————–
fuse = imufilter(‘ReferenceFrame’, ‘NED’,’SampleRate’, 100,’GyroscopeNoise’, 0.0597, ‘AccelerometerNoise’, 3.8416e-04);
[orientazione ,angVelBodyRecovered] = fuse(acc_tot, gyro_tot);
% Plot Euler angles in degrees
A = eulerd(orientazione, ‘ZYX’, ‘frame’);
plot(eulerd(orientazione, ‘ZYX’, ‘frame’));
title(‘Orientation Estimate’);
legend(‘Z-rotation’, ‘Y-rotation’, ‘X-rotation’);
ylabel(‘Degrees’);
% ————— QUA C’E’ LA PARTE PER IL FILTRO ———————–
imuFs_nonHolonomic = 100;
imuFs_imuFilter = 100;
gpsFs = 1;
imuSamplesPerGPS = imuFs_nonHolonomic/gpsFs;
localOrigin = [latitudine(1) longitudine(1) altitudine(1)];
% ——————- DEFINIZIONE NONHOLONOMIC FILTER ———————
filt = insfilterNonholonomic(‘ReferenceFrame’, ‘NED’);
filt.IMUSampleRate = imuFs_nonHolonomic;
filt.ReferenceLocation = localOrigin;
filt.StateCovariance = 1e-6*eye(16);
% parametri del filtro: noise acc e gyro
filt.AccelerometerNoise = 3.8416e-04;
filt.GyroscopeNoise = 0.0597;
Rpos = 0.001 * eye(3);
% ——- LOOP PRINCIPALE PER IL FILTRO ——————-
numIMUSamples = length(tempo_desiderato);
estOrient = quaternion.ones(numIMUSamples,1);
estPos = zeros(numIMUSamples,3);
estVel = zeros(numIMUSamples,3);
gpsIdx = 1;
correzioni = [];
factor_div = round(numIMUSamples/length_gps);
for idx = 1:numIMUSamples
predict(filt, acc_tot(idx,:), gyro_tot(idx,:)); %Predict filter state
tcorrente = tempo_desiderato(idx);
if tempi_gps(gpsIdx+1)<=tcorrente
% if (mod(idx, factor_div) == 0) %Correct filter state….. fai il fuseGPS ogni 1000 campioni (se simulo su 2 minuti)…
%gpsLLA(gpsIdx,:) = [latitudine(gpsIdx,:) longitudine(gpsIdx,:) altitudine(gpsIdx,:)];
%interp1 per gps su tempocorr
prima = pose(filt);
% fusegps(filt, [lat_interp(gpsIdx,:) lon_interp(gpsIdx,:) altitudine(gpsIdx,:)], Rpos);
fusegps(filt, [latitudine(gpsIdx,:) longitudine(gpsIdx,:) altitudine(gpsIdx,:)], Rpos);
dopo = pose(filt);
correzioni = [correzioni; prima, dopo]; %memorizza correzioni GPS
%[estPos(gpsIdx,:), estOrient(gpsIdx,:), estVel(gpsIdx,:)] = pose(filt); %Log estimated pose
gpsIdx = gpsIdx + 1;
end
[estPos(idx,:), estOrient(idx,:), estVel(gpsIdx,:)] = pose(filt);
end
% plot del risultato
plot(xEast,yNorth,’k’);
xlabel(‘x [m]’);
ylabel(‘y [m]’);
hold on
plot(estPos(:,2), estPos(:,1), ‘g’);
The final plot result should be different from what I get, can anyone tell me why?
I can also share the csv files if needed.
Thank you very much,
alberto. good morning, everyone.
i am working on a project to reconstruct a route using data from two sensors: gps and imu. I am working with two arduino boards, on one is integrated the imu while the gps is connected to the other board.
The sensor data is saved to two csv files which I then use in matlab.
The matlab code I have developed is as follows: I load the data from the gps and the imu and implement an extended kalman filter with the nonholonomic filter.
clear;
% carico dati del GPS
data_gps = load(‘C:UsersalberOneDriveDesktopTESIPROVE_CAMPUS14-01 (casa)output_gga.csv’);
% LATITUDINE, LONGITUDINE E ALTITUDINE
latitudine = data_gps(:,1);
longitudine = data_gps(:,2);
altitudine = data_gps(:,3);
time_gps = data_gps(:,4);
origine = [latitudine(1) longitudine(1) altitudine(1)];
%converti in coordinate locali
[xEast, yNorth, zUp] = latlon2local(latitudine, longitudine, altitudine, origine);
% converto il tempo del gps in secondi
tempi_gps_csv = num2str(time_gps);
ore = str2num(tempi_gps_csv(:,1:2));
minuti = str2num(tempi_gps_csv(:,3:4));
secondi = str2num(tempi_gps_csv(:,5:6));
tempi_secondi = ore*3600 + minuti*60 + secondi;
tempo_inizio = tempi_secondi(1);
tempi_gps = tempi_secondi – tempo_inizio;
% carico dati della IMU
data_imu = load(‘C:UsersalberOneDriveDesktopTESIPROVE_CAMPUS14-01 (casa)IMU.csv’);
N = length(data_imu);
accx_origin = data_imu(1:N,1);
accy_origin = data_imu(1:N,2);
accz_origin = data_imu(1:N,3);
acc_tot_origin = [accx_origin accy_origin accz_origin];
gyrox_origin = data_imu(1:N,4);
gyroy_origin = data_imu(1:N,5);
gyroz_origin = data_imu(1:N,6);
gyro_tot_origin = [gyrox_origin gyroy_origin gyroz_origin];
time_imu = data_imu(1:N,7);
% CONVERTO I DATI DI ACCELEROMETRO E GIROSCOPIO
% converto ‘deg/s’ to ‘rad/s’
gyro_tot_rad = convangvel(gyro_tot_origin, ‘deg/s’, ‘rad/s’);
% converto ‘g’ in ‘m/s^2’
acc_tot_meter = convacc(acc_tot_origin, ‘G”s’, ‘m/s^2’);
%converto il tempo della imu in secondi
tempi_imu_csv = num2str(floor(time_imu));
ore = str2num(tempi_imu_csv(:,1:2));
minuti = str2num(tempi_imu_csv(:,3:4));
secondi = str2num(tempi_imu_csv(:,5:6));
tempi_imu = ore*3600 + minuti*60 + secondi + mod(time_imu,1);
tempi_imu = tempi_imu – tempo_inizio;
% vettore tempi per l’operazione di interpolazione
tempo_desiderato = (tempi_imu(1):0.01:tempi_imu(end))’;
% ——— INTERPOLAZIONE ———–
accx = interp1(tempi_imu, acc_tot_meter(:,1), tempo_desiderato); %la time_imu sarebbe il ‘utc.delta_millis’ che calcolo
accy = interp1(tempi_imu, acc_tot_meter(:,2), tempo_desiderato);
accz = interp1(tempi_imu, acc_tot_meter(:,3), tempo_desiderato);
acc_tot = [accx accy accz];
% gyrox = interp1(time_imu, gyrox_origin, tempo_desiderato);
% gyroy = interp1(time_imu, gyroy_origin, tempo_desiderato);
% gyroz = interp1(time_imu, gyroz_origin, tempo_desiderato);
gyrox = interp1(tempi_imu, gyro_tot_rad(:,1), tempo_desiderato);
gyroy = interp1(tempi_imu, gyro_tot_rad(:,2), tempo_desiderato);
gyroz = interp1(tempi_imu, gyro_tot_rad(:,3), tempo_desiderato);
gyro_tot = [gyrox gyroy gyroz];
% vado ad interpolare anche le coord del gps
lat_interp = interp1(tempi_gps, latitudine, tempo_desiderato);
lon_interp = interp1(tempi_gps, longitudine, tempo_desiderato);
alt_interp = interp1(tempi_gps, altitudine, tempo_desiderato);
length_imu = length(acc_tot); %numero di elementi sul file csv
length_gps = length(data_gps);
% —————— IMU FILTER ———————–
fuse = imufilter(‘ReferenceFrame’, ‘NED’,’SampleRate’, 100,’GyroscopeNoise’, 0.0597, ‘AccelerometerNoise’, 3.8416e-04);
[orientazione ,angVelBodyRecovered] = fuse(acc_tot, gyro_tot);
% Plot Euler angles in degrees
A = eulerd(orientazione, ‘ZYX’, ‘frame’);
plot(eulerd(orientazione, ‘ZYX’, ‘frame’));
title(‘Orientation Estimate’);
legend(‘Z-rotation’, ‘Y-rotation’, ‘X-rotation’);
ylabel(‘Degrees’);
% ————— QUA C’E’ LA PARTE PER IL FILTRO ———————–
imuFs_nonHolonomic = 100;
imuFs_imuFilter = 100;
gpsFs = 1;
imuSamplesPerGPS = imuFs_nonHolonomic/gpsFs;
localOrigin = [latitudine(1) longitudine(1) altitudine(1)];
% ——————- DEFINIZIONE NONHOLONOMIC FILTER ———————
filt = insfilterNonholonomic(‘ReferenceFrame’, ‘NED’);
filt.IMUSampleRate = imuFs_nonHolonomic;
filt.ReferenceLocation = localOrigin;
filt.StateCovariance = 1e-6*eye(16);
% parametri del filtro: noise acc e gyro
filt.AccelerometerNoise = 3.8416e-04;
filt.GyroscopeNoise = 0.0597;
Rpos = 0.001 * eye(3);
% ——- LOOP PRINCIPALE PER IL FILTRO ——————-
numIMUSamples = length(tempo_desiderato);
estOrient = quaternion.ones(numIMUSamples,1);
estPos = zeros(numIMUSamples,3);
estVel = zeros(numIMUSamples,3);
gpsIdx = 1;
correzioni = [];
factor_div = round(numIMUSamples/length_gps);
for idx = 1:numIMUSamples
predict(filt, acc_tot(idx,:), gyro_tot(idx,:)); %Predict filter state
tcorrente = tempo_desiderato(idx);
if tempi_gps(gpsIdx+1)<=tcorrente
% if (mod(idx, factor_div) == 0) %Correct filter state….. fai il fuseGPS ogni 1000 campioni (se simulo su 2 minuti)…
%gpsLLA(gpsIdx,:) = [latitudine(gpsIdx,:) longitudine(gpsIdx,:) altitudine(gpsIdx,:)];
%interp1 per gps su tempocorr
prima = pose(filt);
% fusegps(filt, [lat_interp(gpsIdx,:) lon_interp(gpsIdx,:) altitudine(gpsIdx,:)], Rpos);
fusegps(filt, [latitudine(gpsIdx,:) longitudine(gpsIdx,:) altitudine(gpsIdx,:)], Rpos);
dopo = pose(filt);
correzioni = [correzioni; prima, dopo]; %memorizza correzioni GPS
%[estPos(gpsIdx,:), estOrient(gpsIdx,:), estVel(gpsIdx,:)] = pose(filt); %Log estimated pose
gpsIdx = gpsIdx + 1;
end
[estPos(idx,:), estOrient(idx,:), estVel(gpsIdx,:)] = pose(filt);
end
% plot del risultato
plot(xEast,yNorth,’k’);
xlabel(‘x [m]’);
ylabel(‘y [m]’);
hold on
plot(estPos(:,2), estPos(:,1), ‘g’);
The final plot result should be different from what I get, can anyone tell me why?
I can also share the csv files if needed.
Thank you very much,
alberto. nonholonomic filter, gps, fusion data, extended kalman filter, position estimation MATLAB Answers — New Questions
Force super class to not call overloaded methods of the subclass
I have a base class and subclass inheriting from it. Base class has method A. Subclass overloads that method. I want to force the base class to use (only in some places) it’s own method, not the one overloaded by subclass. Is there any way to do it?
Thank youI have a base class and subclass inheriting from it. Base class has method A. Subclass overloads that method. I want to force the base class to use (only in some places) it’s own method, not the one overloaded by subclass. Is there any way to do it?
Thank you I have a base class and subclass inheriting from it. Base class has method A. Subclass overloads that method. I want to force the base class to use (only in some places) it’s own method, not the one overloaded by subclass. Is there any way to do it?
Thank you overloading, inheritance MATLAB Answers — New Questions
How to programe clipping sine wave
TIME =linspace(0,6*pi,200)
SignalVoltage = 7*sin(Time)TIME =linspace(0,6*pi,200)
SignalVoltage = 7*sin(Time) TIME =linspace(0,6*pi,200)
SignalVoltage = 7*sin(Time) #clippingsinewave MATLAB Answers — New Questions
How can I upload files from computer to Matlab Online?
This may be a silly problem ,but I really didn’t find out the solution.Anyway,there’re people saying that you can find a upload button in "Home" Tab,but I really don’t see that.I am just hoping if anyone could show me.
I upload a picture about what I saw in my Matlab Online.Thank you.This may be a silly problem ,but I really didn’t find out the solution.Anyway,there’re people saying that you can find a upload button in "Home" Tab,but I really don’t see that.I am just hoping if anyone could show me.
I upload a picture about what I saw in my Matlab Online.Thank you. This may be a silly problem ,but I really didn’t find out the solution.Anyway,there’re people saying that you can find a upload button in "Home" Tab,but I really don’t see that.I am just hoping if anyone could show me.
I upload a picture about what I saw in my Matlab Online.Thank you. matlab online, matlab_online, distance_learning MATLAB Answers — New Questions
Find faster way than compose to format table
I have a large table of data which needs to be output as a csv and then read into a model. For some reason (which I cannot solve) the model will not take in values with scientific number formating (e.g. very small or large numbers, so 8.8817e-04, rather than 0.000888). To get around this I turn the table into text and use compose, but this is slow as the data are large. I have tried using round, which is fast, but Matlab still displays in scientific notation for some values and these remain in the csv, which does not solve the problem. Any faster ideas welcome!
Here’s an example. Note I know you don’t need all the DateTime info, but it gives the form of the data. In reality I have 30 years of data at least, which is why it is a problem. It also need to use a seperate workstation or HPC as the string/compose lines lead to out of memory problems on my own laptop, even if it can store this size of table ok.
Many thanks!
StartDate=datetime(’01/01/2019 00:00′,’InputFormat’,’dd/MM/yyyy HH:mm’);
EndDate=datetime(’31/10/2020 23:00′,’InputFormat’,’dd/MM/yyyy HH:mm’);
DateTime = StartDate:hours(1):EndDate;
DateTime = DateTime’;
datasize =size(DateTime,1);
No_St = 307;
Data = rand(datasize,No_St);
Test_table = array2table(Data);
Test_table.Time = DateTime;
Test_table = movevars(Test_table,"Time","Before",1);
Table_str = string(Test_table{:,2:end}); %convert to string
Table_str = compose(‘%.6f’,Table_str); %Reduce precisionI have a large table of data which needs to be output as a csv and then read into a model. For some reason (which I cannot solve) the model will not take in values with scientific number formating (e.g. very small or large numbers, so 8.8817e-04, rather than 0.000888). To get around this I turn the table into text and use compose, but this is slow as the data are large. I have tried using round, which is fast, but Matlab still displays in scientific notation for some values and these remain in the csv, which does not solve the problem. Any faster ideas welcome!
Here’s an example. Note I know you don’t need all the DateTime info, but it gives the form of the data. In reality I have 30 years of data at least, which is why it is a problem. It also need to use a seperate workstation or HPC as the string/compose lines lead to out of memory problems on my own laptop, even if it can store this size of table ok.
Many thanks!
StartDate=datetime(’01/01/2019 00:00′,’InputFormat’,’dd/MM/yyyy HH:mm’);
EndDate=datetime(’31/10/2020 23:00′,’InputFormat’,’dd/MM/yyyy HH:mm’);
DateTime = StartDate:hours(1):EndDate;
DateTime = DateTime’;
datasize =size(DateTime,1);
No_St = 307;
Data = rand(datasize,No_St);
Test_table = array2table(Data);
Test_table.Time = DateTime;
Test_table = movevars(Test_table,"Time","Before",1);
Table_str = string(Test_table{:,2:end}); %convert to string
Table_str = compose(‘%.6f’,Table_str); %Reduce precision I have a large table of data which needs to be output as a csv and then read into a model. For some reason (which I cannot solve) the model will not take in values with scientific number formating (e.g. very small or large numbers, so 8.8817e-04, rather than 0.000888). To get around this I turn the table into text and use compose, but this is slow as the data are large. I have tried using round, which is fast, but Matlab still displays in scientific notation for some values and these remain in the csv, which does not solve the problem. Any faster ideas welcome!
Here’s an example. Note I know you don’t need all the DateTime info, but it gives the form of the data. In reality I have 30 years of data at least, which is why it is a problem. It also need to use a seperate workstation or HPC as the string/compose lines lead to out of memory problems on my own laptop, even if it can store this size of table ok.
Many thanks!
StartDate=datetime(’01/01/2019 00:00′,’InputFormat’,’dd/MM/yyyy HH:mm’);
EndDate=datetime(’31/10/2020 23:00′,’InputFormat’,’dd/MM/yyyy HH:mm’);
DateTime = StartDate:hours(1):EndDate;
DateTime = DateTime’;
datasize =size(DateTime,1);
No_St = 307;
Data = rand(datasize,No_St);
Test_table = array2table(Data);
Test_table.Time = DateTime;
Test_table = movevars(Test_table,"Time","Before",1);
Table_str = string(Test_table{:,2:end}); %convert to string
Table_str = compose(‘%.6f’,Table_str); %Reduce precision compose, string, csv MATLAB Answers — New Questions
Which equation is solved with ThermalModel?
With the PDE toolbox, equations of the general form m∂2u∂t2+d∂u∂t−∇·(c∇u)+au=f can be solved. On the other side, I can use the Thermal model object which seems to be very comfortable for solving the heat equation. However, it’s not clearly defined what the parameters stand for. For example, what is ‘HeatFlux’? Is it the variable g in the generalized Neumann boundary condition n · (c∇u)+qu=g? Isn’t there a complete documentation? How can I be sure that the correct problem is solved, when I cannot see the underlying equations?With the PDE toolbox, equations of the general form m∂2u∂t2+d∂u∂t−∇·(c∇u)+au=f can be solved. On the other side, I can use the Thermal model object which seems to be very comfortable for solving the heat equation. However, it’s not clearly defined what the parameters stand for. For example, what is ‘HeatFlux’? Is it the variable g in the generalized Neumann boundary condition n · (c∇u)+qu=g? Isn’t there a complete documentation? How can I be sure that the correct problem is solved, when I cannot see the underlying equations? With the PDE toolbox, equations of the general form m∂2u∂t2+d∂u∂t−∇·(c∇u)+au=f can be solved. On the other side, I can use the Thermal model object which seems to be very comfortable for solving the heat equation. However, it’s not clearly defined what the parameters stand for. For example, what is ‘HeatFlux’? Is it the variable g in the generalized Neumann boundary condition n · (c∇u)+qu=g? Isn’t there a complete documentation? How can I be sure that the correct problem is solved, when I cannot see the underlying equations? thermalmodel, general pde MATLAB Answers — New Questions
How to connect a AR Drone2.0 to MATLAB and fly it.
Hello
I am a student in Japan researching ARDrone2.0.
The other day, my PC broke and I installed a new MATLAB.
Then, when I tried to operate it with "wi-ficontrol" of "AR Drone Simulink Development-Kit V1.1", I was connected to Wi-Fi but the drone did not move.
Is there any other software required to operate the drone?
I would like some support.Hello
I am a student in Japan researching ARDrone2.0.
The other day, my PC broke and I installed a new MATLAB.
Then, when I tried to operate it with "wi-ficontrol" of "AR Drone Simulink Development-Kit V1.1", I was connected to Wi-Fi but the drone did not move.
Is there any other software required to operate the drone?
I would like some support. Hello
I am a student in Japan researching ARDrone2.0.
The other day, my PC broke and I installed a new MATLAB.
Then, when I tried to operate it with "wi-ficontrol" of "AR Drone Simulink Development-Kit V1.1", I was connected to Wi-Fi but the drone did not move.
Is there any other software required to operate the drone?
I would like some support. ardrone, simulink, drone, parrot MATLAB Answers — New Questions
i am trying to find the lqr controller system Transfer function, but getting error as “Arrays have incompatible sizes for this operation.”
% Define system matrices
A = [0 20.95; -709.22 -106.85];
B = [3771.21; 12765.96];
C = [1 0];
D = 0;
% Define the LQR weighting matrices
Q = [0.0057312 0; 0 1]; % Weighting matrix for states
R = 1; % Weighting matrix for control inputs
% Compute LQR gain matrix
K = lqr(A, B, Q, R);
% Augment the system
[n, ~] = size(A);
AA = [A, zeros(n, 1); -C, 0];
BB = [B; 0];
% Construct the closed-loop system
Ac = AA – BB * K;
Bc = BB;
Cc = C;
Dc = D;
% Create state-space model of the closed-loop system
sys_cl = ss(Ac, Bc, Cc, Dc);
% Convert state-space model to transfer function
sys_tf = tf(sys_cl);
% Display the transfer function
disp(‘Transfer Function of the Closed-Loop System with LQR Controller:’);
disp(sys_tf);% Define system matrices
A = [0 20.95; -709.22 -106.85];
B = [3771.21; 12765.96];
C = [1 0];
D = 0;
% Define the LQR weighting matrices
Q = [0.0057312 0; 0 1]; % Weighting matrix for states
R = 1; % Weighting matrix for control inputs
% Compute LQR gain matrix
K = lqr(A, B, Q, R);
% Augment the system
[n, ~] = size(A);
AA = [A, zeros(n, 1); -C, 0];
BB = [B; 0];
% Construct the closed-loop system
Ac = AA – BB * K;
Bc = BB;
Cc = C;
Dc = D;
% Create state-space model of the closed-loop system
sys_cl = ss(Ac, Bc, Cc, Dc);
% Convert state-space model to transfer function
sys_tf = tf(sys_cl);
% Display the transfer function
disp(‘Transfer Function of the Closed-Loop System with LQR Controller:’);
disp(sys_tf); % Define system matrices
A = [0 20.95; -709.22 -106.85];
B = [3771.21; 12765.96];
C = [1 0];
D = 0;
% Define the LQR weighting matrices
Q = [0.0057312 0; 0 1]; % Weighting matrix for states
R = 1; % Weighting matrix for control inputs
% Compute LQR gain matrix
K = lqr(A, B, Q, R);
% Augment the system
[n, ~] = size(A);
AA = [A, zeros(n, 1); -C, 0];
BB = [B; 0];
% Construct the closed-loop system
Ac = AA – BB * K;
Bc = BB;
Cc = C;
Dc = D;
% Create state-space model of the closed-loop system
sys_cl = ss(Ac, Bc, Cc, Dc);
% Convert state-space model to transfer function
sys_tf = tf(sys_cl);
% Display the transfer function
disp(‘Transfer Function of the Closed-Loop System with LQR Controller:’);
disp(sys_tf); lqr controller transfer function MATLAB Answers — New Questions
can you segment with the 3D unet an image with unequal dimensions, like 128x384x128 for example as an input to the model?
I am using the unet 3d segmentation matlab built in function. tyoical inputs to that function is equal spaced dimentioons of 32, 64, 128, 256, and so on. can i input an image of size 128x384x128 to the unet function. if not then why?I am using the unet 3d segmentation matlab built in function. tyoical inputs to that function is equal spaced dimentioons of 32, 64, 128, 256, and so on. can i input an image of size 128x384x128 to the unet function. if not then why? I am using the unet 3d segmentation matlab built in function. tyoical inputs to that function is equal spaced dimentioons of 32, 64, 128, 256, and so on. can i input an image of size 128x384x128 to the unet function. if not then why? neural network, u net, image size MATLAB Answers — New Questions
How to join a clothoid and an circular arc for a smooth transition?
Hey,
I want to create a trajectory for a right turn driving scenario and have calculated x and y coordinates for a clothoid and a circular arc. I can not use Matlab toolboxes, which is why I used series development of sin and cos for the clothoid. As you can see in the picture, there is a change of curvature where I wanted to match up the clothoid and the arc (around x = 6.3 and y = -0.8).
How can I change my code, so there will be a smooth transition for the curvature? I also attached my code.
For the clothoid I used values given in the Euro NCAP Test Protocol from 2023. The clothoid should start with a radius of 1500 m and end with a radius of 8 m to match the radius of the circular arc. The angles are also given, see the picture below for more info.
Thank you so much!
JaneHey,
I want to create a trajectory for a right turn driving scenario and have calculated x and y coordinates for a clothoid and a circular arc. I can not use Matlab toolboxes, which is why I used series development of sin and cos for the clothoid. As you can see in the picture, there is a change of curvature where I wanted to match up the clothoid and the arc (around x = 6.3 and y = -0.8).
How can I change my code, so there will be a smooth transition for the curvature? I also attached my code.
For the clothoid I used values given in the Euro NCAP Test Protocol from 2023. The clothoid should start with a radius of 1500 m and end with a radius of 8 m to match the radius of the circular arc. The angles are also given, see the picture below for more info.
Thank you so much!
Jane Hey,
I want to create a trajectory for a right turn driving scenario and have calculated x and y coordinates for a clothoid and a circular arc. I can not use Matlab toolboxes, which is why I used series development of sin and cos for the clothoid. As you can see in the picture, there is a change of curvature where I wanted to match up the clothoid and the arc (around x = 6.3 and y = -0.8).
How can I change my code, so there will be a smooth transition for the curvature? I also attached my code.
For the clothoid I used values given in the Euro NCAP Test Protocol from 2023. The clothoid should start with a radius of 1500 m and end with a radius of 8 m to match the radius of the circular arc. The angles are also given, see the picture below for more info.
Thank you so much!
Jane clothoid, circular arc MATLAB Answers — New Questions
How to import multiple .mat files to workspace?
Hi,
As cited above, I’m trying to import multiple .mat files (total 72 no. of .mat files) which are at the location as in the code below. However the code doesn’t import the files to the workspace and throws error as below.
files = dir(‘D:RahulData_tokamakdata&plotdata_paper1H-mode dataH-mode bistable modelset1_neoAno_ratio_10beta0.01Contourplot*.mat’);
for i=1:length(files)
load(files(i).name,’-ascii’);
end
ERROR:
Error using load
with regards,
rcHi,
As cited above, I’m trying to import multiple .mat files (total 72 no. of .mat files) which are at the location as in the code below. However the code doesn’t import the files to the workspace and throws error as below.
files = dir(‘D:RahulData_tokamakdata&plotdata_paper1H-mode dataH-mode bistable modelset1_neoAno_ratio_10beta0.01Contourplot*.mat’);
for i=1:length(files)
load(files(i).name,’-ascii’);
end
ERROR:
Error using load
with regards,
rc Hi,
As cited above, I’m trying to import multiple .mat files (total 72 no. of .mat files) which are at the location as in the code below. However the code doesn’t import the files to the workspace and throws error as below.
files = dir(‘D:RahulData_tokamakdata&plotdata_paper1H-mode dataH-mode bistable modelset1_neoAno_ratio_10beta0.01Contourplot*.mat’);
for i=1:length(files)
load(files(i).name,’-ascii’);
end
ERROR:
Error using load
with regards,
rc data import MATLAB Answers — New Questions
Error with MATLAB function findcrossing “too many input arguments”
Ive been doing the MATLAB fundamentals code when I stumbled upon this error.
Initially the Code says:
y0 = 0;
yline(y0)
tzerox = findcrossing(t,x)
tzero
y = findcrossing(t,y)
TASK
Modify the definition of the findcrossing function so that it takes a third input z.
Add a new line to the beginning of the function:y = y – z;
In the Task 1 section of the script, change the value of y0 to 0.4.
Modify the two calls to findcrossing to add y0 as an input.
You can use the graph to check that the returned values of t are correct (x(t) = 0.4 and y(t) = 0.4)
I modified the code:
y0 = 0.4;
yline(y0)
tzerox = findcrossing(t,x,y0)
tzeroy = findcrossing(t,y,y0)
which is also the solution provided by MATLAB itself, but it says "Error using zerofunction>findcrossing. Too many input arguments".Ive been doing the MATLAB fundamentals code when I stumbled upon this error.
Initially the Code says:
y0 = 0;
yline(y0)
tzerox = findcrossing(t,x)
tzero
y = findcrossing(t,y)
TASK
Modify the definition of the findcrossing function so that it takes a third input z.
Add a new line to the beginning of the function:y = y – z;
In the Task 1 section of the script, change the value of y0 to 0.4.
Modify the two calls to findcrossing to add y0 as an input.
You can use the graph to check that the returned values of t are correct (x(t) = 0.4 and y(t) = 0.4)
I modified the code:
y0 = 0.4;
yline(y0)
tzerox = findcrossing(t,x,y0)
tzeroy = findcrossing(t,y,y0)
which is also the solution provided by MATLAB itself, but it says "Error using zerofunction>findcrossing. Too many input arguments". Ive been doing the MATLAB fundamentals code when I stumbled upon this error.
Initially the Code says:
y0 = 0;
yline(y0)
tzerox = findcrossing(t,x)
tzero
y = findcrossing(t,y)
TASK
Modify the definition of the findcrossing function so that it takes a third input z.
Add a new line to the beginning of the function:y = y – z;
In the Task 1 section of the script, change the value of y0 to 0.4.
Modify the two calls to findcrossing to add y0 as an input.
You can use the graph to check that the returned values of t are correct (x(t) = 0.4 and y(t) = 0.4)
I modified the code:
y0 = 0.4;
yline(y0)
tzerox = findcrossing(t,x,y0)
tzeroy = findcrossing(t,y,y0)
which is also the solution provided by MATLAB itself, but it says "Error using zerofunction>findcrossing. Too many input arguments". error, matlab function MATLAB Answers — New Questions
How do I make simulink model for self excited induction generator?
I have made a Simulink model for a grid connected induction generator by implementing the various voltage and torque equations of an induction generator in various blocks. I want to modify it to a self-excited induction generator by replacing the 3 phase source by a star/delta connected capacitor bank.But how can I provide the residual magnetism for the generator to start in this case?
I have attached the above stated file.I have made a Simulink model for a grid connected induction generator by implementing the various voltage and torque equations of an induction generator in various blocks. I want to modify it to a self-excited induction generator by replacing the 3 phase source by a star/delta connected capacitor bank.But how can I provide the residual magnetism for the generator to start in this case?
I have attached the above stated file. I have made a Simulink model for a grid connected induction generator by implementing the various voltage and torque equations of an induction generator in various blocks. I want to modify it to a self-excited induction generator by replacing the 3 phase source by a star/delta connected capacitor bank.But how can I provide the residual magnetism for the generator to start in this case?
I have attached the above stated file. induction generator, machine, self-excited induction generator MATLAB Answers — New Questions