Tag Archives: matlab
How to control PWM servo driver for arduino from Simulink?
I’m looking for libraries/support to control a PWM driver module (PCA9685) connected to arduino from Simulink. I’m not very skilled with the Arduino add on, so I don’t really know how to send I2C commands to the module fromSimulink.I’m looking for libraries/support to control a PWM driver module (PCA9685) connected to arduino from Simulink. I’m not very skilled with the Arduino add on, so I don’t really know how to send I2C commands to the module fromSimulink. I’m looking for libraries/support to control a PWM driver module (PCA9685) connected to arduino from Simulink. I’m not very skilled with the Arduino add on, so I don’t really know how to send I2C commands to the module fromSimulink. pca9685, simulink MATLAB Answers — New Questions
Is there any command for .xlsx file to import directly to Signal Builder.
I have some inputs recived from user in .xlsx file need to import it into Signal Builder using commands. It can be done manually but i need it with commands which can be done automatically.
Steps:
a. xlsx file needs to be imported from other folders of Desktop.
b. While importing .xlsx file which needs path.
c. Then it should select sheets and replace existing data–> apply –> ok.I have some inputs recived from user in .xlsx file need to import it into Signal Builder using commands. It can be done manually but i need it with commands which can be done automatically.
Steps:
a. xlsx file needs to be imported from other folders of Desktop.
b. While importing .xlsx file which needs path.
c. Then it should select sheets and replace existing data–> apply –> ok. I have some inputs recived from user in .xlsx file need to import it into Signal Builder using commands. It can be done manually but i need it with commands which can be done automatically.
Steps:
a. xlsx file needs to be imported from other folders of Desktop.
b. While importing .xlsx file which needs path.
c. Then it should select sheets and replace existing data–> apply –> ok. m-scripting, signal builder, simulink, matlab MATLAB Answers — New Questions
tic toc delayed output inside for loop
I want to use the tic toc function to time each iteration of a for loop. Usually, this outputs the time as "Elapsed time is … seconds." in the command window after each loop iteration. So for the following example code there would be an output approximately every 0.1 seconds on my machine.
for j = 1:20
tic
eig(rand(500));
toc
end
However, since a few days the outputs to the command window are only made after the loop finishes and I get all the 20 outputs for the 20 iterations at once in the end. I don’t understand why this changed, I didn’t (knowingly) change any settings and couldn’t find anything, so maybe it is a bug? I updated my release version hoping that would fix it, but it didn’t. I know that this behavior happens when you use tic toc inside a for loop, while a parallel pool is open, but in this case there is no parallel pool. Is there something I can do to get the old behavior where the elapsed time is printed to the command window after each iteration?I want to use the tic toc function to time each iteration of a for loop. Usually, this outputs the time as "Elapsed time is … seconds." in the command window after each loop iteration. So for the following example code there would be an output approximately every 0.1 seconds on my machine.
for j = 1:20
tic
eig(rand(500));
toc
end
However, since a few days the outputs to the command window are only made after the loop finishes and I get all the 20 outputs for the 20 iterations at once in the end. I don’t understand why this changed, I didn’t (knowingly) change any settings and couldn’t find anything, so maybe it is a bug? I updated my release version hoping that would fix it, but it didn’t. I know that this behavior happens when you use tic toc inside a for loop, while a parallel pool is open, but in this case there is no parallel pool. Is there something I can do to get the old behavior where the elapsed time is printed to the command window after each iteration? I want to use the tic toc function to time each iteration of a for loop. Usually, this outputs the time as "Elapsed time is … seconds." in the command window after each loop iteration. So for the following example code there would be an output approximately every 0.1 seconds on my machine.
for j = 1:20
tic
eig(rand(500));
toc
end
However, since a few days the outputs to the command window are only made after the loop finishes and I get all the 20 outputs for the 20 iterations at once in the end. I don’t understand why this changed, I didn’t (knowingly) change any settings and couldn’t find anything, so maybe it is a bug? I updated my release version hoping that would fix it, but it didn’t. I know that this behavior happens when you use tic toc inside a for loop, while a parallel pool is open, but in this case there is no parallel pool. Is there something I can do to get the old behavior where the elapsed time is printed to the command window after each iteration? timing, for loop MATLAB Answers — New Questions
How to log out of matlab drive account?
I have two matlab accounts and two PCs, each PC with an account. Recently I need to synchronize my m files, so I tried to use matlab drive. I logged out of my first account from one PC and logged in another one, but the account on matlab drive (which should also log out) remained unchanged even if I had restarted the PC. There also seems no setup on Matlab Connector for log in and out.I have two matlab accounts and two PCs, each PC with an account. Recently I need to synchronize my m files, so I tried to use matlab drive. I logged out of my first account from one PC and logged in another one, but the account on matlab drive (which should also log out) remained unchanged even if I had restarted the PC. There also seems no setup on Matlab Connector for log in and out. I have two matlab accounts and two PCs, each PC with an account. Recently I need to synchronize my m files, so I tried to use matlab drive. I logged out of my first account from one PC and logged in another one, but the account on matlab drive (which should also log out) remained unchanged even if I had restarted the PC. There also seems no setup on Matlab Connector for log in and out. matlab drive, account, matlab connector MATLAB Answers — New Questions
How to set YLim for multiple Yaxis on UIaxes
I am plotting a figure using uiaxes in app designer with 2 y axis one on the left and other on the right. And I am trying to set YLim for both left and right. But the code I wrote was wrong. The one I right for the right is overwriting the one on the left. So technically I am only setting YLim for the left one.
yyaxis(app.UIAxes_4,’left’);
plot(app.UIAxes_4,app.actualTime,app.Charge_Current);
app.UIAxes_4.XMinorGrid ="on";
app.UIAxes_4.YMinorGrid ="on";
app.UIAxes_4.YLabel.String = ‘Current [A]’;
app.UIAxes_4.YLabel.FontSize = 12;
app.UIAxes_4.YLabel.FontWeight ="bold";
app.UIAxes_4.YLim = [app.Y1min app.Y1max]; % This sets the YLim correctly for the left side
yyaxis(app.UIAxes,’right’);
plot(app.UIAxes,app.actualTime,voltage);
app.UIAxes.XMinorGrid ="on";
app.UIAxes.YMinorGrid ="on";
app.UIAxes.YLabel.String = ‘Current [A]’;
app.UIAxes.YLabel.FontSize = 12;
app.UIAxes.YLabel.FontWeight ="bold";
app.UIAxes_4.YLim = [app.Y2min app.Y2max]; % This overrides the Ylim set earlier and sets a new YLim for
% left side without setting
% Ylim for the right side.
What is the way to set Ylim on both left and right. Thank you.I am plotting a figure using uiaxes in app designer with 2 y axis one on the left and other on the right. And I am trying to set YLim for both left and right. But the code I wrote was wrong. The one I right for the right is overwriting the one on the left. So technically I am only setting YLim for the left one.
yyaxis(app.UIAxes_4,’left’);
plot(app.UIAxes_4,app.actualTime,app.Charge_Current);
app.UIAxes_4.XMinorGrid ="on";
app.UIAxes_4.YMinorGrid ="on";
app.UIAxes_4.YLabel.String = ‘Current [A]’;
app.UIAxes_4.YLabel.FontSize = 12;
app.UIAxes_4.YLabel.FontWeight ="bold";
app.UIAxes_4.YLim = [app.Y1min app.Y1max]; % This sets the YLim correctly for the left side
yyaxis(app.UIAxes,’right’);
plot(app.UIAxes,app.actualTime,voltage);
app.UIAxes.XMinorGrid ="on";
app.UIAxes.YMinorGrid ="on";
app.UIAxes.YLabel.String = ‘Current [A]’;
app.UIAxes.YLabel.FontSize = 12;
app.UIAxes.YLabel.FontWeight ="bold";
app.UIAxes_4.YLim = [app.Y2min app.Y2max]; % This overrides the Ylim set earlier and sets a new YLim for
% left side without setting
% Ylim for the right side.
What is the way to set Ylim on both left and right. Thank you. I am plotting a figure using uiaxes in app designer with 2 y axis one on the left and other on the right. And I am trying to set YLim for both left and right. But the code I wrote was wrong. The one I right for the right is overwriting the one on the left. So technically I am only setting YLim for the left one.
yyaxis(app.UIAxes_4,’left’);
plot(app.UIAxes_4,app.actualTime,app.Charge_Current);
app.UIAxes_4.XMinorGrid ="on";
app.UIAxes_4.YMinorGrid ="on";
app.UIAxes_4.YLabel.String = ‘Current [A]’;
app.UIAxes_4.YLabel.FontSize = 12;
app.UIAxes_4.YLabel.FontWeight ="bold";
app.UIAxes_4.YLim = [app.Y1min app.Y1max]; % This sets the YLim correctly for the left side
yyaxis(app.UIAxes,’right’);
plot(app.UIAxes,app.actualTime,voltage);
app.UIAxes.XMinorGrid ="on";
app.UIAxes.YMinorGrid ="on";
app.UIAxes.YLabel.String = ‘Current [A]’;
app.UIAxes.YLabel.FontSize = 12;
app.UIAxes.YLabel.FontWeight ="bold";
app.UIAxes_4.YLim = [app.Y2min app.Y2max]; % This overrides the Ylim set earlier and sets a new YLim for
% left side without setting
% Ylim for the right side.
What is the way to set Ylim on both left and right. Thank you. matlab, appdesigner MATLAB Answers — New Questions
Inline equation in MATLAB Document object
Hi everyone,
The MATLAB RPT doc example shows how to put inline equation into a Report.
However, I am not using Report. I am just using Document. Can I do inline equation in a Document object?
Thanks
KevinHi everyone,
The MATLAB RPT doc example shows how to put inline equation into a Report.
However, I am not using Report. I am just using Document. Can I do inline equation in a Document object?
Thanks
Kevin Hi everyone,
The MATLAB RPT doc example shows how to put inline equation into a Report.
However, I am not using Report. I am just using Document. Can I do inline equation in a Document object?
Thanks
Kevin inline equation MATLAB Answers — New Questions
Label more than 7 lines in a plot
Hi,
I am realizing that after 7 lines, Matlab seems to run out of colors for graphs and legends..is that
correct? Currently I am plotting the following:
plot(matA);
legend(‘1.’,’2.’,’3.’,’4.’,’5.’,’6.’,’7.’,’8.’);
xlabel(‘Timepoints’);
ylabel(‘Sources’);
matA is a 200×8 matrix, but after plotting I see that the lines 1 and 8 both have the same colors..what
is the easiest way out?
ThanksHi,
I am realizing that after 7 lines, Matlab seems to run out of colors for graphs and legends..is that
correct? Currently I am plotting the following:
plot(matA);
legend(‘1.’,’2.’,’3.’,’4.’,’5.’,’6.’,’7.’,’8.’);
xlabel(‘Timepoints’);
ylabel(‘Sources’);
matA is a 200×8 matrix, but after plotting I see that the lines 1 and 8 both have the same colors..what
is the easiest way out?
Thanks Hi,
I am realizing that after 7 lines, Matlab seems to run out of colors for graphs and legends..is that
correct? Currently I am plotting the following:
plot(matA);
legend(‘1.’,’2.’,’3.’,’4.’,’5.’,’6.’,’7.’,’8.’);
xlabel(‘Timepoints’);
ylabel(‘Sources’);
matA is a 200×8 matrix, but after plotting I see that the lines 1 and 8 both have the same colors..what
is the easiest way out?
Thanks plot MATLAB Answers — New Questions
Contour plot with polar stereoghapic projection in north hemispehere above 60 degree latitude
Hi,
I have ut(24), lat(24) and z (24×24); data attached as .mat. I want to plot a contour plot in polar stereographic projection for northern hemisphere above 60 degree latitude (something like attached ). I tried with m_map polar sterographic projection.
m_proj(‘stereographic’,’lat’,90,’long’,30,’radius’,60);
m_elev(‘contour’,[0:0.00009:1],’edgecolor’,’b’);
m_grid(‘xtick’,12,’tickdir’,’in’,’ytick’,[60:10:90],’linest’,’-‘);
m_coast(‘linewidth’,1,’linestyle’,’-‘,’color’,’k’);
I got the image as completely different.
I also tried using like https://jp.mathworks.com/matlabcentral/answers/170145-how-to-plot-contourf-data-on-m-map-polar-stereographic-projection, the plot it is not in sterographic projection. Can anyone help.Hi,
I have ut(24), lat(24) and z (24×24); data attached as .mat. I want to plot a contour plot in polar stereographic projection for northern hemisphere above 60 degree latitude (something like attached ). I tried with m_map polar sterographic projection.
m_proj(‘stereographic’,’lat’,90,’long’,30,’radius’,60);
m_elev(‘contour’,[0:0.00009:1],’edgecolor’,’b’);
m_grid(‘xtick’,12,’tickdir’,’in’,’ytick’,[60:10:90],’linest’,’-‘);
m_coast(‘linewidth’,1,’linestyle’,’-‘,’color’,’k’);
I got the image as completely different.
I also tried using like https://jp.mathworks.com/matlabcentral/answers/170145-how-to-plot-contourf-data-on-m-map-polar-stereographic-projection, the plot it is not in sterographic projection. Can anyone help. Hi,
I have ut(24), lat(24) and z (24×24); data attached as .mat. I want to plot a contour plot in polar stereographic projection for northern hemisphere above 60 degree latitude (something like attached ). I tried with m_map polar sterographic projection.
m_proj(‘stereographic’,’lat’,90,’long’,30,’radius’,60);
m_elev(‘contour’,[0:0.00009:1],’edgecolor’,’b’);
m_grid(‘xtick’,12,’tickdir’,’in’,’ytick’,[60:10:90],’linest’,’-‘);
m_coast(‘linewidth’,1,’linestyle’,’-‘,’color’,’k’);
I got the image as completely different.
I also tried using like https://jp.mathworks.com/matlabcentral/answers/170145-how-to-plot-contourf-data-on-m-map-polar-stereographic-projection, the plot it is not in sterographic projection. Can anyone help. contourf, stereographic, polar, matlab2023a MATLAB Answers — New Questions
Issue with DTC of PMSM at 40kHz PWM Frequency
I are currently using "Direct Torque Control of PMSM Using Quadrature Encoder or Sensorless Flux Observer" example for high-speed PMSM motor control. The system works perfectly at 20kHz, but when I increase the PWM frequency to 40kHz, I encounter an issue with the reference speed in the host model.
For example, when I set the reference speed to 500 RPM, the host model incorrectly shows 6500 RPM. It appears that the instructed or reference speed is getting corrupted during transmission or processing. I’ve attempted various solutions, including adjusting the baud rate, hardware interrupts, and hardware initialization settings, but the issue persists.I are currently using "Direct Torque Control of PMSM Using Quadrature Encoder or Sensorless Flux Observer" example for high-speed PMSM motor control. The system works perfectly at 20kHz, but when I increase the PWM frequency to 40kHz, I encounter an issue with the reference speed in the host model.
For example, when I set the reference speed to 500 RPM, the host model incorrectly shows 6500 RPM. It appears that the instructed or reference speed is getting corrupted during transmission or processing. I’ve attempted various solutions, including adjusting the baud rate, hardware interrupts, and hardware initialization settings, but the issue persists. I are currently using "Direct Torque Control of PMSM Using Quadrature Encoder or Sensorless Flux Observer" example for high-speed PMSM motor control. The system works perfectly at 20kHz, but when I increase the PWM frequency to 40kHz, I encounter an issue with the reference speed in the host model.
For example, when I set the reference speed to 500 RPM, the host model incorrectly shows 6500 RPM. It appears that the instructed or reference speed is getting corrupted during transmission or processing. I’ve attempted various solutions, including adjusting the baud rate, hardware interrupts, and hardware initialization settings, but the issue persists. dtc, 40khz pwm MATLAB Answers — New Questions
Trying to implement Vulnerable Road User scenario using SIMULINK
Hello Programmers,
Having gone through YouTube and ChatGpt, I observed there is no much details on using the ‘Autonomous Vehicle’ toolbox especially for VRU scenario. I was thinking of learning this for scenarios in the C-v2x. Any help?Hello Programmers,
Having gone through YouTube and ChatGpt, I observed there is no much details on using the ‘Autonomous Vehicle’ toolbox especially for VRU scenario. I was thinking of learning this for scenarios in the C-v2x. Any help? Hello Programmers,
Having gone through YouTube and ChatGpt, I observed there is no much details on using the ‘Autonomous Vehicle’ toolbox especially for VRU scenario. I was thinking of learning this for scenarios in the C-v2x. Any help? autonomous vehicle, vulnerable road user, simulink, c-v2x MATLAB Answers — New Questions
How do I make a desktop launcher for MATLAB in Linux?
I don’t want to have to open a terminal window every time I want to launch MATLAB on Linux. I tried to make a Gnome launcher, but it does not seem to work. The command I gave was:
/usr/local/bin/matlab &
I see the process running, but now windows appear. What am I doing wrong?I don’t want to have to open a terminal window every time I want to launch MATLAB on Linux. I tried to make a Gnome launcher, but it does not seem to work. The command I gave was:
/usr/local/bin/matlab &
I see the process running, but now windows appear. What am I doing wrong? I don’t want to have to open a terminal window every time I want to launch MATLAB on Linux. I tried to make a Gnome launcher, but it does not seem to work. The command I gave was:
/usr/local/bin/matlab &
I see the process running, but now windows appear. What am I doing wrong? startup, linux, launcher, command MATLAB Answers — New Questions
Issue with plotting order
Hello,
I have been trying to plot a shaded area (right y-axis) behind two lines (left y-axis), as shown in the code below. However, the shaded area always appears last, covering up the two lines. I’ve done this kind of graph before but have never had this issue. Best I can tell, it is because the right y-axis is plotted last. Is there a way to make the right y-axis plotted first? I can’t simply switch which data is on the axis, unfortunately: they need to be in this order. Thanks for any help!
clear; clc; close all;
Data = xlsread("FigureOfMeritResults.xlsx");
% Extract data
Date = Data(469:1908,1);
FoM = Data(469:1908,3);
GHI = Data(469:1908,4);
% Calculate the running average over 5 data points
FoM_avg = movmean(FoM, 5);
GHI_avg = movmean(GHI, 5);
dFoM = zeros(length(FoM),1) + mean(FoM);
ticks = {’12:00AM’,’4:00AM’,’8:00AM’,’12:00PM’,’4:00PM’,’8:00PM’,’12:00AM’};
fz = 15;
%%
fig = figure;
set(gcf,’Color’,’w’,’Units’,’inches’)
set(gcf,’Position’,[1,1,5,6])
GHI_color = [0.8 0.8 1];
yyaxis left;
p1 = scatter(Date, FoM, ‘Marker’, ‘.’, ‘SizeData’, 15, ‘MarkerFaceColor’, "#0072BD");
hold on;
p2 = scatter(Date, dFoM, ‘Marker’, ‘_’, ‘SizeData’, 15, ‘MarkerFaceColor’, ‘black’);
hold on;
ax = gca;
ax.YColor = ‘k’;
yyaxis right;
xData = [Date; flipud(Date)];
yData = [zeros(size(GHI)); flipud(GHI)];
fillHandle = fill(xData, yData, GHI_color,’EdgeColor’,’none’);
hold on;
ax = gca;
ax.YColor = ‘k’;
xlabel(‘Time of Day (hrs)’, ‘FontSize’, fz);
numTicks = length(ticks);
tickPositions = linspace(min(Date), max(Date), numTicks);
xticks(tickPositions);
xticklabels(ticks);
set(gca, ‘FontSize’, fz);
ax = gca;
box on;
set(ax,’BoxStyle’,’full’,’LineWidth’,2,’XGrid’,’off’,’XMinorTick’,’off’,’YGrid’,’off’,…
‘YMinorTick’,’on’);Hello,
I have been trying to plot a shaded area (right y-axis) behind two lines (left y-axis), as shown in the code below. However, the shaded area always appears last, covering up the two lines. I’ve done this kind of graph before but have never had this issue. Best I can tell, it is because the right y-axis is plotted last. Is there a way to make the right y-axis plotted first? I can’t simply switch which data is on the axis, unfortunately: they need to be in this order. Thanks for any help!
clear; clc; close all;
Data = xlsread("FigureOfMeritResults.xlsx");
% Extract data
Date = Data(469:1908,1);
FoM = Data(469:1908,3);
GHI = Data(469:1908,4);
% Calculate the running average over 5 data points
FoM_avg = movmean(FoM, 5);
GHI_avg = movmean(GHI, 5);
dFoM = zeros(length(FoM),1) + mean(FoM);
ticks = {’12:00AM’,’4:00AM’,’8:00AM’,’12:00PM’,’4:00PM’,’8:00PM’,’12:00AM’};
fz = 15;
%%
fig = figure;
set(gcf,’Color’,’w’,’Units’,’inches’)
set(gcf,’Position’,[1,1,5,6])
GHI_color = [0.8 0.8 1];
yyaxis left;
p1 = scatter(Date, FoM, ‘Marker’, ‘.’, ‘SizeData’, 15, ‘MarkerFaceColor’, "#0072BD");
hold on;
p2 = scatter(Date, dFoM, ‘Marker’, ‘_’, ‘SizeData’, 15, ‘MarkerFaceColor’, ‘black’);
hold on;
ax = gca;
ax.YColor = ‘k’;
yyaxis right;
xData = [Date; flipud(Date)];
yData = [zeros(size(GHI)); flipud(GHI)];
fillHandle = fill(xData, yData, GHI_color,’EdgeColor’,’none’);
hold on;
ax = gca;
ax.YColor = ‘k’;
xlabel(‘Time of Day (hrs)’, ‘FontSize’, fz);
numTicks = length(ticks);
tickPositions = linspace(min(Date), max(Date), numTicks);
xticks(tickPositions);
xticklabels(ticks);
set(gca, ‘FontSize’, fz);
ax = gca;
box on;
set(ax,’BoxStyle’,’full’,’LineWidth’,2,’XGrid’,’off’,’XMinorTick’,’off’,’YGrid’,’off’,…
‘YMinorTick’,’on’); Hello,
I have been trying to plot a shaded area (right y-axis) behind two lines (left y-axis), as shown in the code below. However, the shaded area always appears last, covering up the two lines. I’ve done this kind of graph before but have never had this issue. Best I can tell, it is because the right y-axis is plotted last. Is there a way to make the right y-axis plotted first? I can’t simply switch which data is on the axis, unfortunately: they need to be in this order. Thanks for any help!
clear; clc; close all;
Data = xlsread("FigureOfMeritResults.xlsx");
% Extract data
Date = Data(469:1908,1);
FoM = Data(469:1908,3);
GHI = Data(469:1908,4);
% Calculate the running average over 5 data points
FoM_avg = movmean(FoM, 5);
GHI_avg = movmean(GHI, 5);
dFoM = zeros(length(FoM),1) + mean(FoM);
ticks = {’12:00AM’,’4:00AM’,’8:00AM’,’12:00PM’,’4:00PM’,’8:00PM’,’12:00AM’};
fz = 15;
%%
fig = figure;
set(gcf,’Color’,’w’,’Units’,’inches’)
set(gcf,’Position’,[1,1,5,6])
GHI_color = [0.8 0.8 1];
yyaxis left;
p1 = scatter(Date, FoM, ‘Marker’, ‘.’, ‘SizeData’, 15, ‘MarkerFaceColor’, "#0072BD");
hold on;
p2 = scatter(Date, dFoM, ‘Marker’, ‘_’, ‘SizeData’, 15, ‘MarkerFaceColor’, ‘black’);
hold on;
ax = gca;
ax.YColor = ‘k’;
yyaxis right;
xData = [Date; flipud(Date)];
yData = [zeros(size(GHI)); flipud(GHI)];
fillHandle = fill(xData, yData, GHI_color,’EdgeColor’,’none’);
hold on;
ax = gca;
ax.YColor = ‘k’;
xlabel(‘Time of Day (hrs)’, ‘FontSize’, fz);
numTicks = length(ticks);
tickPositions = linspace(min(Date), max(Date), numTicks);
xticks(tickPositions);
xticklabels(ticks);
set(gca, ‘FontSize’, fz);
ax = gca;
box on;
set(ax,’BoxStyle’,’full’,’LineWidth’,2,’XGrid’,’off’,’XMinorTick’,’off’,’YGrid’,’off’,…
‘YMinorTick’,’on’); plot, area MATLAB Answers — New Questions
How to read the properties information of kml data
I got geographical information using ‘readgeotable’,
but I want to bring properties information of actual kml data.
In more detail, I would like to bring each field within the kml data and the property information corresponding to the field.
Is there any way?I got geographical information using ‘readgeotable’,
but I want to bring properties information of actual kml data.
In more detail, I would like to bring each field within the kml data and the property information corresponding to the field.
Is there any way? I got geographical information using ‘readgeotable’,
but I want to bring properties information of actual kml data.
In more detail, I would like to bring each field within the kml data and the property information corresponding to the field.
Is there any way? kml, readtable MATLAB Answers — New Questions
Periodic result using ode45 while simulating a parachute decent with 6DOF dynamics
So I’ve been trying to simulate a parachute descent (very basic model, almost a mass body with a coefficient of drag), from a height. While simulating only in the axial direction(z axis), the results coincide with kinematics equations. However, when I give a non-zero initial condition, the outputs go crazy (definitely not correct) with periodic solutions to related terms. I seem to have checked my equations, they seem to be right. Is there anything with ‘odeset’ I can work this out around.
Zero non-axial initial condition:
x0 = [0; 0; -100; 0; 0; 1; 0; 0; 0; 0; 0; 0];
Non-zero IC:
x0 = [0; 0; -100; 0; 1; 1; 0; 0; 0; 0; 0; 0];
0
this is the code i’ve used for these plots. Please feel free to ask any clarifications
%% 6DOF fucntion definition
function [dxdt, aoa_series] = six_DOF_dynamics(t,x)
M_para = 5; %mass of the parachute in Kgs
g = 9.81; %gravitational acceleration in m/s^2
I_x = 1; I_y = 1; I_z = 3; %Inertia matrix diagonal principal of the parachute in kg-m^2
CD_para = 0.9; %coefficient of drag of parachute
CL_para = 0; %coefficient of lift of parachute
rho = 1; %density of the atmosphere in Kg/m^3
x_com = 0; y_com = 0; z_com = -5; %position of COM of the paarchute from the integrated system’s COM(body axis origin) in m
A = 10; %parachute area in m^2
%state variables defining
x_pos = x(1); y_pos = x(2); z_pos = x(3); %postion variables
u = x(4); v = x(5); w = x(6); %velocity variables
phi = x(7); theta = x(8); psi = x(9); %attitude/euler angles variables
p = x(10); q = x(11); r = x(12); %euler angular rate variables
%rate of change of postion -> velocity
dx_pos = u;
dy_pos = v;
dz_pos = w;
%Gravity moment of the parachute along x,y and z components
GravityMoment_para_x = M_para*g*cos(theta)*(y_com*cos(phi) – z_com*sin(phi));
GravityMoment_para_y = M_para*g*(z_com*sin(theta) – x_com*cos(theta)*cos(phi));
GravityMoment_para_z = M_para*g*(x_com*cos(theta)*sin(phi) + y_com*sin(theta));
V_total = sqrt(u^2 + v^2 + w^2); %net speed
persistent angle_of_attack %defining this variable to take it as a output outside ode45
alpha = acos(w/V_total); %angle of attack calculated in radians
angle_of_attack = [angle_of_attack; alpha]; %concatinating current iterated angle of attack in global variable
%Componetize CD and CL into tangential and normal force coefficients
CT = CD_para*cos(alpha) – CL_para*sin(alpha);
CN = CL_para*cos(alpha) + CD_para*sin(alpha);
% Aerodynamic force along x,y,z axes F = 0.5*rho*v^2*A
if (u == 0 & v == 0)
Aerodynamic_force_x = 0;
Aerodynamic_force_y = 0;
Aerodynamic_force_z = -0.5*rho*CT*V_total*V_total*A;
else
Aerodynamic_force_x = -0.5*rho*CN*V_total*V_total*A*(u/(u^2 + v^2)^0.5);
Aerodynamic_force_y = -0.5*rho*CN*V_total*V_total*A*(v/(u^2 + v^2)^0.5);
Aerodynamic_force_z = -0.5*rho*CT*V_total*V_total*A;
end
%Moment caused by aerodynamic force along x,y,x
Aerodynamic_moment_x = y_com*Aerodynamic_force_z – z_com*Aerodynamic_force_y;
Aerodynamic_moment_y = z_com*Aerodynamic_force_x – x_com*Aerodynamic_force_z;
Aerodynamic_moment_z = x_com*Aerodynamic_force_y – y_com*Aerodynamic_force_x;
%rate change of velocity definition
du = v*r – w*q + g*sin(theta) + Aerodynamic_force_x/M_para;
dv = -u*r + w*p + g*cos(theta)*sin(phi) + Aerodynamic_force_y/M_para;
dw = u*q – v*p + g*cos(theta)*cos(phi) + Aerodynamic_force_z/M_para;
%rate change of euler angles definition
dphi = p + (r*cos(phi) + q*sin(phi))*tan(theta);
dtheta = q*cos(phi) – r*sin(phi);
dpsi = (cos(theta)^-1)*(r*cos(phi) + q*sin(phi));
%rate change of angular rates definition
dp = (1/I_x)*(Aerodynamic_moment_x + GravityMoment_para_x);
dq = (1/I_y)*(Aerodynamic_moment_y + GravityMoment_para_y);
dr = (1/I_z)*(Aerodynamic_moment_z + GravityMoment_para_z);
dxdt = [dx_pos; dy_pos; dz_pos; du; dv; dw; dphi; dtheta; dpsi; dp; dq; dr];
%block to output angle of attack
if nargout>1
aoa_series = angle_of_attack;
end
end
tspan = [0 3];
x0 = [0; 0; -100; 0; 1; 1; 0; 0; 0; 0; 0; 0];
[t, x] = ode45(@six_DOF_dynamics, tspan, x0);
[~, aoa_series] = six_DOF_dynamics(t,x);
%adding alpha as a part of x
% Plot results
figure;
subplot(4,1,1);
plot(t, x(:,1:3));
title(‘Position’);
legend(‘x’, ‘y’, ‘z’);
subplot(4,1,2);
plot(t, x(:,4:6));
title(‘Velocity’);
legend(‘u’, ‘v’, ‘w’);
subplot(4,1,3);
plot(t, x(:,7:9));
title(‘Euler Angles’);
legend(‘phi’, ‘theta’, ‘psi’);
subplot(4,1,4);
plot(t, x(:,10:12));
title(‘Euler Rates’);
legend(‘p’, ‘q’, ‘r’);So I’ve been trying to simulate a parachute descent (very basic model, almost a mass body with a coefficient of drag), from a height. While simulating only in the axial direction(z axis), the results coincide with kinematics equations. However, when I give a non-zero initial condition, the outputs go crazy (definitely not correct) with periodic solutions to related terms. I seem to have checked my equations, they seem to be right. Is there anything with ‘odeset’ I can work this out around.
Zero non-axial initial condition:
x0 = [0; 0; -100; 0; 0; 1; 0; 0; 0; 0; 0; 0];
Non-zero IC:
x0 = [0; 0; -100; 0; 1; 1; 0; 0; 0; 0; 0; 0];
0
this is the code i’ve used for these plots. Please feel free to ask any clarifications
%% 6DOF fucntion definition
function [dxdt, aoa_series] = six_DOF_dynamics(t,x)
M_para = 5; %mass of the parachute in Kgs
g = 9.81; %gravitational acceleration in m/s^2
I_x = 1; I_y = 1; I_z = 3; %Inertia matrix diagonal principal of the parachute in kg-m^2
CD_para = 0.9; %coefficient of drag of parachute
CL_para = 0; %coefficient of lift of parachute
rho = 1; %density of the atmosphere in Kg/m^3
x_com = 0; y_com = 0; z_com = -5; %position of COM of the paarchute from the integrated system’s COM(body axis origin) in m
A = 10; %parachute area in m^2
%state variables defining
x_pos = x(1); y_pos = x(2); z_pos = x(3); %postion variables
u = x(4); v = x(5); w = x(6); %velocity variables
phi = x(7); theta = x(8); psi = x(9); %attitude/euler angles variables
p = x(10); q = x(11); r = x(12); %euler angular rate variables
%rate of change of postion -> velocity
dx_pos = u;
dy_pos = v;
dz_pos = w;
%Gravity moment of the parachute along x,y and z components
GravityMoment_para_x = M_para*g*cos(theta)*(y_com*cos(phi) – z_com*sin(phi));
GravityMoment_para_y = M_para*g*(z_com*sin(theta) – x_com*cos(theta)*cos(phi));
GravityMoment_para_z = M_para*g*(x_com*cos(theta)*sin(phi) + y_com*sin(theta));
V_total = sqrt(u^2 + v^2 + w^2); %net speed
persistent angle_of_attack %defining this variable to take it as a output outside ode45
alpha = acos(w/V_total); %angle of attack calculated in radians
angle_of_attack = [angle_of_attack; alpha]; %concatinating current iterated angle of attack in global variable
%Componetize CD and CL into tangential and normal force coefficients
CT = CD_para*cos(alpha) – CL_para*sin(alpha);
CN = CL_para*cos(alpha) + CD_para*sin(alpha);
% Aerodynamic force along x,y,z axes F = 0.5*rho*v^2*A
if (u == 0 & v == 0)
Aerodynamic_force_x = 0;
Aerodynamic_force_y = 0;
Aerodynamic_force_z = -0.5*rho*CT*V_total*V_total*A;
else
Aerodynamic_force_x = -0.5*rho*CN*V_total*V_total*A*(u/(u^2 + v^2)^0.5);
Aerodynamic_force_y = -0.5*rho*CN*V_total*V_total*A*(v/(u^2 + v^2)^0.5);
Aerodynamic_force_z = -0.5*rho*CT*V_total*V_total*A;
end
%Moment caused by aerodynamic force along x,y,x
Aerodynamic_moment_x = y_com*Aerodynamic_force_z – z_com*Aerodynamic_force_y;
Aerodynamic_moment_y = z_com*Aerodynamic_force_x – x_com*Aerodynamic_force_z;
Aerodynamic_moment_z = x_com*Aerodynamic_force_y – y_com*Aerodynamic_force_x;
%rate change of velocity definition
du = v*r – w*q + g*sin(theta) + Aerodynamic_force_x/M_para;
dv = -u*r + w*p + g*cos(theta)*sin(phi) + Aerodynamic_force_y/M_para;
dw = u*q – v*p + g*cos(theta)*cos(phi) + Aerodynamic_force_z/M_para;
%rate change of euler angles definition
dphi = p + (r*cos(phi) + q*sin(phi))*tan(theta);
dtheta = q*cos(phi) – r*sin(phi);
dpsi = (cos(theta)^-1)*(r*cos(phi) + q*sin(phi));
%rate change of angular rates definition
dp = (1/I_x)*(Aerodynamic_moment_x + GravityMoment_para_x);
dq = (1/I_y)*(Aerodynamic_moment_y + GravityMoment_para_y);
dr = (1/I_z)*(Aerodynamic_moment_z + GravityMoment_para_z);
dxdt = [dx_pos; dy_pos; dz_pos; du; dv; dw; dphi; dtheta; dpsi; dp; dq; dr];
%block to output angle of attack
if nargout>1
aoa_series = angle_of_attack;
end
end
tspan = [0 3];
x0 = [0; 0; -100; 0; 1; 1; 0; 0; 0; 0; 0; 0];
[t, x] = ode45(@six_DOF_dynamics, tspan, x0);
[~, aoa_series] = six_DOF_dynamics(t,x);
%adding alpha as a part of x
% Plot results
figure;
subplot(4,1,1);
plot(t, x(:,1:3));
title(‘Position’);
legend(‘x’, ‘y’, ‘z’);
subplot(4,1,2);
plot(t, x(:,4:6));
title(‘Velocity’);
legend(‘u’, ‘v’, ‘w’);
subplot(4,1,3);
plot(t, x(:,7:9));
title(‘Euler Angles’);
legend(‘phi’, ‘theta’, ‘psi’);
subplot(4,1,4);
plot(t, x(:,10:12));
title(‘Euler Rates’);
legend(‘p’, ‘q’, ‘r’); So I’ve been trying to simulate a parachute descent (very basic model, almost a mass body with a coefficient of drag), from a height. While simulating only in the axial direction(z axis), the results coincide with kinematics equations. However, when I give a non-zero initial condition, the outputs go crazy (definitely not correct) with periodic solutions to related terms. I seem to have checked my equations, they seem to be right. Is there anything with ‘odeset’ I can work this out around.
Zero non-axial initial condition:
x0 = [0; 0; -100; 0; 0; 1; 0; 0; 0; 0; 0; 0];
Non-zero IC:
x0 = [0; 0; -100; 0; 1; 1; 0; 0; 0; 0; 0; 0];
0
this is the code i’ve used for these plots. Please feel free to ask any clarifications
%% 6DOF fucntion definition
function [dxdt, aoa_series] = six_DOF_dynamics(t,x)
M_para = 5; %mass of the parachute in Kgs
g = 9.81; %gravitational acceleration in m/s^2
I_x = 1; I_y = 1; I_z = 3; %Inertia matrix diagonal principal of the parachute in kg-m^2
CD_para = 0.9; %coefficient of drag of parachute
CL_para = 0; %coefficient of lift of parachute
rho = 1; %density of the atmosphere in Kg/m^3
x_com = 0; y_com = 0; z_com = -5; %position of COM of the paarchute from the integrated system’s COM(body axis origin) in m
A = 10; %parachute area in m^2
%state variables defining
x_pos = x(1); y_pos = x(2); z_pos = x(3); %postion variables
u = x(4); v = x(5); w = x(6); %velocity variables
phi = x(7); theta = x(8); psi = x(9); %attitude/euler angles variables
p = x(10); q = x(11); r = x(12); %euler angular rate variables
%rate of change of postion -> velocity
dx_pos = u;
dy_pos = v;
dz_pos = w;
%Gravity moment of the parachute along x,y and z components
GravityMoment_para_x = M_para*g*cos(theta)*(y_com*cos(phi) – z_com*sin(phi));
GravityMoment_para_y = M_para*g*(z_com*sin(theta) – x_com*cos(theta)*cos(phi));
GravityMoment_para_z = M_para*g*(x_com*cos(theta)*sin(phi) + y_com*sin(theta));
V_total = sqrt(u^2 + v^2 + w^2); %net speed
persistent angle_of_attack %defining this variable to take it as a output outside ode45
alpha = acos(w/V_total); %angle of attack calculated in radians
angle_of_attack = [angle_of_attack; alpha]; %concatinating current iterated angle of attack in global variable
%Componetize CD and CL into tangential and normal force coefficients
CT = CD_para*cos(alpha) – CL_para*sin(alpha);
CN = CL_para*cos(alpha) + CD_para*sin(alpha);
% Aerodynamic force along x,y,z axes F = 0.5*rho*v^2*A
if (u == 0 & v == 0)
Aerodynamic_force_x = 0;
Aerodynamic_force_y = 0;
Aerodynamic_force_z = -0.5*rho*CT*V_total*V_total*A;
else
Aerodynamic_force_x = -0.5*rho*CN*V_total*V_total*A*(u/(u^2 + v^2)^0.5);
Aerodynamic_force_y = -0.5*rho*CN*V_total*V_total*A*(v/(u^2 + v^2)^0.5);
Aerodynamic_force_z = -0.5*rho*CT*V_total*V_total*A;
end
%Moment caused by aerodynamic force along x,y,x
Aerodynamic_moment_x = y_com*Aerodynamic_force_z – z_com*Aerodynamic_force_y;
Aerodynamic_moment_y = z_com*Aerodynamic_force_x – x_com*Aerodynamic_force_z;
Aerodynamic_moment_z = x_com*Aerodynamic_force_y – y_com*Aerodynamic_force_x;
%rate change of velocity definition
du = v*r – w*q + g*sin(theta) + Aerodynamic_force_x/M_para;
dv = -u*r + w*p + g*cos(theta)*sin(phi) + Aerodynamic_force_y/M_para;
dw = u*q – v*p + g*cos(theta)*cos(phi) + Aerodynamic_force_z/M_para;
%rate change of euler angles definition
dphi = p + (r*cos(phi) + q*sin(phi))*tan(theta);
dtheta = q*cos(phi) – r*sin(phi);
dpsi = (cos(theta)^-1)*(r*cos(phi) + q*sin(phi));
%rate change of angular rates definition
dp = (1/I_x)*(Aerodynamic_moment_x + GravityMoment_para_x);
dq = (1/I_y)*(Aerodynamic_moment_y + GravityMoment_para_y);
dr = (1/I_z)*(Aerodynamic_moment_z + GravityMoment_para_z);
dxdt = [dx_pos; dy_pos; dz_pos; du; dv; dw; dphi; dtheta; dpsi; dp; dq; dr];
%block to output angle of attack
if nargout>1
aoa_series = angle_of_attack;
end
end
tspan = [0 3];
x0 = [0; 0; -100; 0; 1; 1; 0; 0; 0; 0; 0; 0];
[t, x] = ode45(@six_DOF_dynamics, tspan, x0);
[~, aoa_series] = six_DOF_dynamics(t,x);
%adding alpha as a part of x
% Plot results
figure;
subplot(4,1,1);
plot(t, x(:,1:3));
title(‘Position’);
legend(‘x’, ‘y’, ‘z’);
subplot(4,1,2);
plot(t, x(:,4:6));
title(‘Velocity’);
legend(‘u’, ‘v’, ‘w’);
subplot(4,1,3);
plot(t, x(:,7:9));
title(‘Euler Angles’);
legend(‘phi’, ‘theta’, ‘psi’);
subplot(4,1,4);
plot(t, x(:,10:12));
title(‘Euler Rates’);
legend(‘p’, ‘q’, ‘r’); 6dof, parachute, periodic MATLAB Answers — New Questions
Optimizing Hyperparameters for trainnet fucntion
Hi there I have built my own TCN model in matlab to predict a contunious output and am trying to figure out the best way to optimize the hyperparmeters: Filter Size, Number of Filters, Number of Blocks, and Drop out Factor. I am attempting to use the bayespot function, but am not sure what to use as my function handel and if this is the best method for this kind of network. Should I be using the experiment manger to do this instead (https://www.mathworks.com/help/deeplearning/ug/tune-experiment-hyperparameters-using-bayesian-optimization.html) Does anyone have an suggestions for my code or if there is another way to perform hyperparmeter optimization for this type of network achetecture? Thanks so much.
%Network
numFilters = 64;
filterSize = 5;
droupoutFactor = 0.005;
numBlocks = 5;
net = dlnetwork;
layer = sequenceInputLayer(numFeatures,Normalization="rescale-symmetric",Name="input");
net = addLayers(net,layer);
for i = 1:numBlocks
dilationFactor = 2^(i-1);
layers = [
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal",Name="conv1_"+i)
layerNormalizationLayer
spatialDropoutLayer(Name= "spat_drop_"+i,Probability=droupoutFactor)
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal")
layerNormalizationLayer
reluLayer
spatialDropoutLayer(Name="spat_drop2_"+i,Probability=droupoutFactor)
additionLayer(2,Name="add_"+i)];
% Add and connect layers.
net = addLayers(net,layers);
net = connectLayers(net,outputName,"conv1_"+i);
end
net = connectLayers(net,outputName,"fc");
%Training Options
options = trainingOptions("adam", …
‘MaxEpochs’, 60, …
‘MiniBatchSize’, 1, …
‘InputDataFormat’, "CTB", …
‘Metrics’, "rmse", …
‘Verbose’, 0);
filtsize = optimizableVariable(‘filterSize’,[1,10],’Type’,’integer’)
numfilt = optimizableVariable(‘numFilters’,[20,60],’Type’,’integer’)
numblock = optimizableVariable(‘numBlocks’,[1,10],’Type’,’integer’)
dropout = optimizableVariable(‘dropoutfactor’,[0.001,0.01],’Type’,’integer’)
net = trainnet(traningdataX,trainingdataY,net,"mse",options);
fun = (x)@ %Not sure what to put here!
reuslts = bayesopt(,[filtsize, numfilt, numblock, droupout])Hi there I have built my own TCN model in matlab to predict a contunious output and am trying to figure out the best way to optimize the hyperparmeters: Filter Size, Number of Filters, Number of Blocks, and Drop out Factor. I am attempting to use the bayespot function, but am not sure what to use as my function handel and if this is the best method for this kind of network. Should I be using the experiment manger to do this instead (https://www.mathworks.com/help/deeplearning/ug/tune-experiment-hyperparameters-using-bayesian-optimization.html) Does anyone have an suggestions for my code or if there is another way to perform hyperparmeter optimization for this type of network achetecture? Thanks so much.
%Network
numFilters = 64;
filterSize = 5;
droupoutFactor = 0.005;
numBlocks = 5;
net = dlnetwork;
layer = sequenceInputLayer(numFeatures,Normalization="rescale-symmetric",Name="input");
net = addLayers(net,layer);
for i = 1:numBlocks
dilationFactor = 2^(i-1);
layers = [
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal",Name="conv1_"+i)
layerNormalizationLayer
spatialDropoutLayer(Name= "spat_drop_"+i,Probability=droupoutFactor)
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal")
layerNormalizationLayer
reluLayer
spatialDropoutLayer(Name="spat_drop2_"+i,Probability=droupoutFactor)
additionLayer(2,Name="add_"+i)];
% Add and connect layers.
net = addLayers(net,layers);
net = connectLayers(net,outputName,"conv1_"+i);
end
net = connectLayers(net,outputName,"fc");
%Training Options
options = trainingOptions("adam", …
‘MaxEpochs’, 60, …
‘MiniBatchSize’, 1, …
‘InputDataFormat’, "CTB", …
‘Metrics’, "rmse", …
‘Verbose’, 0);
filtsize = optimizableVariable(‘filterSize’,[1,10],’Type’,’integer’)
numfilt = optimizableVariable(‘numFilters’,[20,60],’Type’,’integer’)
numblock = optimizableVariable(‘numBlocks’,[1,10],’Type’,’integer’)
dropout = optimizableVariable(‘dropoutfactor’,[0.001,0.01],’Type’,’integer’)
net = trainnet(traningdataX,trainingdataY,net,"mse",options);
fun = (x)@ %Not sure what to put here!
reuslts = bayesopt(,[filtsize, numfilt, numblock, droupout]) Hi there I have built my own TCN model in matlab to predict a contunious output and am trying to figure out the best way to optimize the hyperparmeters: Filter Size, Number of Filters, Number of Blocks, and Drop out Factor. I am attempting to use the bayespot function, but am not sure what to use as my function handel and if this is the best method for this kind of network. Should I be using the experiment manger to do this instead (https://www.mathworks.com/help/deeplearning/ug/tune-experiment-hyperparameters-using-bayesian-optimization.html) Does anyone have an suggestions for my code or if there is another way to perform hyperparmeter optimization for this type of network achetecture? Thanks so much.
%Network
numFilters = 64;
filterSize = 5;
droupoutFactor = 0.005;
numBlocks = 5;
net = dlnetwork;
layer = sequenceInputLayer(numFeatures,Normalization="rescale-symmetric",Name="input");
net = addLayers(net,layer);
for i = 1:numBlocks
dilationFactor = 2^(i-1);
layers = [
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal",Name="conv1_"+i)
layerNormalizationLayer
spatialDropoutLayer(Name= "spat_drop_"+i,Probability=droupoutFactor)
convolution1dLayer(filterSize,numFilters,DilationFactor=dilationFactor,Padding="causal")
layerNormalizationLayer
reluLayer
spatialDropoutLayer(Name="spat_drop2_"+i,Probability=droupoutFactor)
additionLayer(2,Name="add_"+i)];
% Add and connect layers.
net = addLayers(net,layers);
net = connectLayers(net,outputName,"conv1_"+i);
end
net = connectLayers(net,outputName,"fc");
%Training Options
options = trainingOptions("adam", …
‘MaxEpochs’, 60, …
‘MiniBatchSize’, 1, …
‘InputDataFormat’, "CTB", …
‘Metrics’, "rmse", …
‘Verbose’, 0);
filtsize = optimizableVariable(‘filterSize’,[1,10],’Type’,’integer’)
numfilt = optimizableVariable(‘numFilters’,[20,60],’Type’,’integer’)
numblock = optimizableVariable(‘numBlocks’,[1,10],’Type’,’integer’)
dropout = optimizableVariable(‘dropoutfactor’,[0.001,0.01],’Type’,’integer’)
net = trainnet(traningdataX,trainingdataY,net,"mse",options);
fun = (x)@ %Not sure what to put here!
reuslts = bayesopt(,[filtsize, numfilt, numblock, droupout]) optimization, machine learning, hyperparameters MATLAB Answers — New Questions
Can I use the fitcensemble function to create a Random Forest model?
I am new to machine learning classifiers.
I want to develop a Random Forest classification model with my IMU data.
I used the code below, and my question is: Can I call it a Random Forest model, or should I just call it a bagging ensemble model?
baggedEnsemble = fitcensemble(data_train(:,2:end), data_train(:,1),’Method’,’Bag’,’NumLearningCycles’,100);I am new to machine learning classifiers.
I want to develop a Random Forest classification model with my IMU data.
I used the code below, and my question is: Can I call it a Random Forest model, or should I just call it a bagging ensemble model?
baggedEnsemble = fitcensemble(data_train(:,2:end), data_train(:,1),’Method’,’Bag’,’NumLearningCycles’,100); I am new to machine learning classifiers.
I want to develop a Random Forest classification model with my IMU data.
I used the code below, and my question is: Can I call it a Random Forest model, or should I just call it a bagging ensemble model?
baggedEnsemble = fitcensemble(data_train(:,2:end), data_train(:,1),’Method’,’Bag’,’NumLearningCycles’,100); machine learning, random forest, ensemble, bagging, classification MATLAB Answers — New Questions
Questions about the Detailed Settings of Voronoi Diagrams ボロノイ図の細かな設定について質問です
I have been reading an example from a book and am trying to recreate the diagram using Voronoi diagrams. However, I want to consider a bounded region [0,1], [1,0], but when using the voronoi function, the lines extend beyond the boundaries. I would like to obtain information such as the area and centroid of the bounded regions, so I want to create the Voronoi diagram with these bounded constraints in mind. Is this possible?
ある書籍の例を読み、ボロノイ図を用いてその図を再現したいと考えています。
しかし有界の領域[0,1],[1,0]について考えたいところ、voronoiでは枠外を超えて線が伸びてしまいます。
有界領域の面積や重心などの情報を得たいため、ボロノイ図を有界の制約を踏まえて作成したいのですが可能でしょうか?
clear
close all
figure()
x = [0.2 0.6 0.9 0.7 0.8 0.5 0.4 0.1 0.3 0.5];
y = [0.7 0.9 0.8 0.6 0.3 0.4 0.2 0.1 0.3 0.5];
X = [x’,y’];
vrn_obj = voronoi(X(:,1),X(:,2));
[vx,vy] = voronoi(X(:,1),X(:,2));
edge_set =[vx’,vy’];
nump = size(X,1);
plabels = arrayfun(@(n) {sprintf(‘X%d’, n)}, (1:nump)’);
hold on
Hpl = text(X(:,1), X(:,2), plabels, ‘FontWeight’, …
‘bold’, ‘HorizontalAlignment’,’center’, …
‘BackgroundColor’, ‘none’);
dt = delaunayTriangulation(X);
hold on
triplot(dt,’–‘);
hold off
axis equal
% xlim([0 1])
% ylim([0 1])
grid onI have been reading an example from a book and am trying to recreate the diagram using Voronoi diagrams. However, I want to consider a bounded region [0,1], [1,0], but when using the voronoi function, the lines extend beyond the boundaries. I would like to obtain information such as the area and centroid of the bounded regions, so I want to create the Voronoi diagram with these bounded constraints in mind. Is this possible?
ある書籍の例を読み、ボロノイ図を用いてその図を再現したいと考えています。
しかし有界の領域[0,1],[1,0]について考えたいところ、voronoiでは枠外を超えて線が伸びてしまいます。
有界領域の面積や重心などの情報を得たいため、ボロノイ図を有界の制約を踏まえて作成したいのですが可能でしょうか?
clear
close all
figure()
x = [0.2 0.6 0.9 0.7 0.8 0.5 0.4 0.1 0.3 0.5];
y = [0.7 0.9 0.8 0.6 0.3 0.4 0.2 0.1 0.3 0.5];
X = [x’,y’];
vrn_obj = voronoi(X(:,1),X(:,2));
[vx,vy] = voronoi(X(:,1),X(:,2));
edge_set =[vx’,vy’];
nump = size(X,1);
plabels = arrayfun(@(n) {sprintf(‘X%d’, n)}, (1:nump)’);
hold on
Hpl = text(X(:,1), X(:,2), plabels, ‘FontWeight’, …
‘bold’, ‘HorizontalAlignment’,’center’, …
‘BackgroundColor’, ‘none’);
dt = delaunayTriangulation(X);
hold on
triplot(dt,’–‘);
hold off
axis equal
% xlim([0 1])
% ylim([0 1])
grid on I have been reading an example from a book and am trying to recreate the diagram using Voronoi diagrams. However, I want to consider a bounded region [0,1], [1,0], but when using the voronoi function, the lines extend beyond the boundaries. I would like to obtain information such as the area and centroid of the bounded regions, so I want to create the Voronoi diagram with these bounded constraints in mind. Is this possible?
ある書籍の例を読み、ボロノイ図を用いてその図を再現したいと考えています。
しかし有界の領域[0,1],[1,0]について考えたいところ、voronoiでは枠外を超えて線が伸びてしまいます。
有界領域の面積や重心などの情報を得たいため、ボロノイ図を有界の制約を踏まえて作成したいのですが可能でしょうか?
clear
close all
figure()
x = [0.2 0.6 0.9 0.7 0.8 0.5 0.4 0.1 0.3 0.5];
y = [0.7 0.9 0.8 0.6 0.3 0.4 0.2 0.1 0.3 0.5];
X = [x’,y’];
vrn_obj = voronoi(X(:,1),X(:,2));
[vx,vy] = voronoi(X(:,1),X(:,2));
edge_set =[vx’,vy’];
nump = size(X,1);
plabels = arrayfun(@(n) {sprintf(‘X%d’, n)}, (1:nump)’);
hold on
Hpl = text(X(:,1), X(:,2), plabels, ‘FontWeight’, …
‘bold’, ‘HorizontalAlignment’,’center’, …
‘BackgroundColor’, ‘none’);
dt = delaunayTriangulation(X);
hold on
triplot(dt,’–‘);
hold off
axis equal
% xlim([0 1])
% ylim([0 1])
grid on plot, matlab, graph MATLAB Answers — New Questions
C2000 Modbus RTU Slave
Hi,
I’m programming a DSP TMS320F28069M using Simulink. I have successfully received data and unpack that receive data via uint16 format. And I use a matlab function block. This reason that I used, to compare the required bits for Modbus communication. Although byte unpack block output type is uint16, I couldn’t use this receive value. For example, let the SCI received data be ’01 02 00 00 00 00 02 10′. First of compare the first byte. If first byte is 01, transmits the eighth byte. But if not sends second byte. I always saw the second byte was gone. I guess received or compare data type is wrong but I couldn’t find it. I changed the value C1 instead of 01 in the if loop. When I enter the C1 byte into the system, an error occurs How can I do this?
Inside the function block:Hi,
I’m programming a DSP TMS320F28069M using Simulink. I have successfully received data and unpack that receive data via uint16 format. And I use a matlab function block. This reason that I used, to compare the required bits for Modbus communication. Although byte unpack block output type is uint16, I couldn’t use this receive value. For example, let the SCI received data be ’01 02 00 00 00 00 02 10′. First of compare the first byte. If first byte is 01, transmits the eighth byte. But if not sends second byte. I always saw the second byte was gone. I guess received or compare data type is wrong but I couldn’t find it. I changed the value C1 instead of 01 in the if loop. When I enter the C1 byte into the system, an error occurs How can I do this?
Inside the function block: Hi,
I’m programming a DSP TMS320F28069M using Simulink. I have successfully received data and unpack that receive data via uint16 format. And I use a matlab function block. This reason that I used, to compare the required bits for Modbus communication. Although byte unpack block output type is uint16, I couldn’t use this receive value. For example, let the SCI received data be ’01 02 00 00 00 00 02 10′. First of compare the first byte. If first byte is 01, transmits the eighth byte. But if not sends second byte. I always saw the second byte was gone. I guess received or compare data type is wrong but I couldn’t find it. I changed the value C1 instead of 01 in the if loop. When I enter the C1 byte into the system, an error occurs How can I do this?
Inside the function block: modbus, sci MATLAB Answers — New Questions
how to separate the real and imaginary parts inside a cell
i have a cell of size 1X2. inside the cell there are 2 matrices of size 32X32. i want to separate the real and imaginary of both the matrices that is inside the cell the two matrices should be 32X32X2. and finally i want the size to be 2X32X32X2. How to do it.i have a cell of size 1X2. inside the cell there are 2 matrices of size 32X32. i want to separate the real and imaginary of both the matrices that is inside the cell the two matrices should be 32X32X2. and finally i want the size to be 2X32X32X2. How to do it. i have a cell of size 1X2. inside the cell there are 2 matrices of size 32X32. i want to separate the real and imaginary of both the matrices that is inside the cell the two matrices should be 32X32X2. and finally i want the size to be 2X32X32X2. How to do it. cell array, real, imaginary MATLAB Answers — New Questions
Chapter and section number is not increased in report generator.
Chapter and section number is not increased in report generator.
I use mlreportgen.report, mlerportgen.dom class.Chapter and section number is not increased in report generator.
I use mlreportgen.report, mlerportgen.dom class. Chapter and section number is not increased in report generator.
I use mlreportgen.report, mlerportgen.dom class. simulink, report generator, mlreportgen MATLAB Answers — New Questions