Category: Matlab
Category Archives: Matlab
Slice Displaying Grids Instead of Color
Just like the title said, I have a problem with displaying the correct slice. I attach the said generated figure below. Also this is my test script:
tas = ncread("datadary_ATM.2023030100.nc", "ta");
lat = ncread("datadary_ATM.2023030100.nc", "lat");
lon = ncread("datadary_ATM.2023030100.nc", "lon");
kz = ncread("datadary_ATM.2023030100.nc", "kz");
time = ncread("datadary_ATM.2023030100.nc", "time");
ta = ncread("datadary_ATM.2023030100.nc", "ta"); ta = ta – 273.15;
ua = ncread("datadary_ATM.2023030100.nc", "ua"); ua = ua(:, :, 1, 4);
va = ncread("datadary_ATM.2023030100.nc", "va"); va = va(:, :, 1, 4);
wa = ncread("datadary_ATM.2023030100.nc", "wa"); wa = wa(:, :, 1, 4);
[longrid, latgrid] = meshgrid(lon, lat);
kzlevel = 18;
kz2d = kz(kzlevel) * ones(size(longrid));
[x,y,z] = meshgrid(lon, lat, kz);
ta = squeeze(ta(:,:,:,1));
figure;
slice(x,y,z,ta,[],[],1:4);
colormap("turbo");
colorbar;
clim([0 50]);
axis xy;Just like the title said, I have a problem with displaying the correct slice. I attach the said generated figure below. Also this is my test script:
tas = ncread("datadary_ATM.2023030100.nc", "ta");
lat = ncread("datadary_ATM.2023030100.nc", "lat");
lon = ncread("datadary_ATM.2023030100.nc", "lon");
kz = ncread("datadary_ATM.2023030100.nc", "kz");
time = ncread("datadary_ATM.2023030100.nc", "time");
ta = ncread("datadary_ATM.2023030100.nc", "ta"); ta = ta – 273.15;
ua = ncread("datadary_ATM.2023030100.nc", "ua"); ua = ua(:, :, 1, 4);
va = ncread("datadary_ATM.2023030100.nc", "va"); va = va(:, :, 1, 4);
wa = ncread("datadary_ATM.2023030100.nc", "wa"); wa = wa(:, :, 1, 4);
[longrid, latgrid] = meshgrid(lon, lat);
kzlevel = 18;
kz2d = kz(kzlevel) * ones(size(longrid));
[x,y,z] = meshgrid(lon, lat, kz);
ta = squeeze(ta(:,:,:,1));
figure;
slice(x,y,z,ta,[],[],1:4);
colormap("turbo");
colorbar;
clim([0 50]);
axis xy; Just like the title said, I have a problem with displaying the correct slice. I attach the said generated figure below. Also this is my test script:
tas = ncread("datadary_ATM.2023030100.nc", "ta");
lat = ncread("datadary_ATM.2023030100.nc", "lat");
lon = ncread("datadary_ATM.2023030100.nc", "lon");
kz = ncread("datadary_ATM.2023030100.nc", "kz");
time = ncread("datadary_ATM.2023030100.nc", "time");
ta = ncread("datadary_ATM.2023030100.nc", "ta"); ta = ta – 273.15;
ua = ncread("datadary_ATM.2023030100.nc", "ua"); ua = ua(:, :, 1, 4);
va = ncread("datadary_ATM.2023030100.nc", "va"); va = va(:, :, 1, 4);
wa = ncread("datadary_ATM.2023030100.nc", "wa"); wa = wa(:, :, 1, 4);
[longrid, latgrid] = meshgrid(lon, lat);
kzlevel = 18;
kz2d = kz(kzlevel) * ones(size(longrid));
[x,y,z] = meshgrid(lon, lat, kz);
ta = squeeze(ta(:,:,:,1));
figure;
slice(x,y,z,ta,[],[],1:4);
colormap("turbo");
colorbar;
clim([0 50]);
axis xy; 4d, visualization, slice MATLAB Answers — New Questions
How can I get the new coordinates of a point after rotation of an image (2D)?
I have got the coordinates of a point (P) in my main image (2D). The main image (im) is now rotated using imrotate and the angle alpha. Now, I want to know what the coordinates of P are in the rotated image.
P = [5;8]; % coordinates of point
alpha = 45; % angle for rotation
RotatedIm = imrotate(im,alpha); % rotation of the main image (im)
RotMatrix = [cosd(alpha) -sind(alpha); sind(alpha) cosd(alpha)];
ImCenter = (size(im)/2)’; % Center of the main image
RotatedP = RotMatrix*(P-ImCenter)+ImCenter; % Rotation of point P over center of the image with angle alpha
The rotatedP coordinates are not the right ones. The problem is that there are zeros added on the borders of RotatedIm. I think that that is the reason why the coordinates of RotatedP are not correct. Can someone help me to find the coordinates of point P in the rotated image?I have got the coordinates of a point (P) in my main image (2D). The main image (im) is now rotated using imrotate and the angle alpha. Now, I want to know what the coordinates of P are in the rotated image.
P = [5;8]; % coordinates of point
alpha = 45; % angle for rotation
RotatedIm = imrotate(im,alpha); % rotation of the main image (im)
RotMatrix = [cosd(alpha) -sind(alpha); sind(alpha) cosd(alpha)];
ImCenter = (size(im)/2)’; % Center of the main image
RotatedP = RotMatrix*(P-ImCenter)+ImCenter; % Rotation of point P over center of the image with angle alpha
The rotatedP coordinates are not the right ones. The problem is that there are zeros added on the borders of RotatedIm. I think that that is the reason why the coordinates of RotatedP are not correct. Can someone help me to find the coordinates of point P in the rotated image? I have got the coordinates of a point (P) in my main image (2D). The main image (im) is now rotated using imrotate and the angle alpha. Now, I want to know what the coordinates of P are in the rotated image.
P = [5;8]; % coordinates of point
alpha = 45; % angle for rotation
RotatedIm = imrotate(im,alpha); % rotation of the main image (im)
RotMatrix = [cosd(alpha) -sind(alpha); sind(alpha) cosd(alpha)];
ImCenter = (size(im)/2)’; % Center of the main image
RotatedP = RotMatrix*(P-ImCenter)+ImCenter; % Rotation of point P over center of the image with angle alpha
The rotatedP coordinates are not the right ones. The problem is that there are zeros added on the borders of RotatedIm. I think that that is the reason why the coordinates of RotatedP are not correct. Can someone help me to find the coordinates of point P in the rotated image? imrotate, rotation matrix MATLAB Answers — New Questions
Stop Windows MATLAB adjusting figure’s position and size
I am writing some MATLAB code to export some graphics, which is "large". I tested my code on Windows system and I found that the position and size of the figure were adjusted.
I looked up the Help Center and saw the note (figure properties) as follows.
The Windows operating system enforces a minimum window width and a maximum window size. If you specify a figure size outside of those limits, the displayed figure will conform to the limits instead of the size you specified.
I wonder if there is some approah can stop Windows from changing the figure or adjust the minimum window width and maximum window size on Windows MATLAB?I am writing some MATLAB code to export some graphics, which is "large". I tested my code on Windows system and I found that the position and size of the figure were adjusted.
I looked up the Help Center and saw the note (figure properties) as follows.
The Windows operating system enforces a minimum window width and a maximum window size. If you specify a figure size outside of those limits, the displayed figure will conform to the limits instead of the size you specified.
I wonder if there is some approah can stop Windows from changing the figure or adjust the minimum window width and maximum window size on Windows MATLAB? I am writing some MATLAB code to export some graphics, which is "large". I tested my code on Windows system and I found that the position and size of the figure were adjusted.
I looked up the Help Center and saw the note (figure properties) as follows.
The Windows operating system enforces a minimum window width and a maximum window size. If you specify a figure size outside of those limits, the displayed figure will conform to the limits instead of the size you specified.
I wonder if there is some approah can stop Windows from changing the figure or adjust the minimum window width and maximum window size on Windows MATLAB? figure, plotting, windows, size, position MATLAB Answers — New Questions
How to apply bank angle in Vehicle composer app?
Hi, I’m currently trying to figure out how to apply road bank angle to an environment in Simulink via a virtual vehicle composer app. Most of the blocks seem to be utilised from the vehicle dynamics blockset library, but it seems difficult to account for this in the ‘VehicleBody6DOF’ block or the ‘MFtire’ block itself. Do you have any recommendations? I’m having a hard time figuring out how to deform the model.Hi, I’m currently trying to figure out how to apply road bank angle to an environment in Simulink via a virtual vehicle composer app. Most of the blocks seem to be utilised from the vehicle dynamics blockset library, but it seems difficult to account for this in the ‘VehicleBody6DOF’ block or the ‘MFtire’ block itself. Do you have any recommendations? I’m having a hard time figuring out how to deform the model. Hi, I’m currently trying to figure out how to apply road bank angle to an environment in Simulink via a virtual vehicle composer app. Most of the blocks seem to be utilised from the vehicle dynamics blockset library, but it seems difficult to account for this in the ‘VehicleBody6DOF’ block or the ‘MFtire’ block itself. Do you have any recommendations? I’m having a hard time figuring out how to deform the model. simulink, vehicle dynamics MATLAB Answers — New Questions
How to set environment variables on Raspberry PI for deployment of TFLite on Pi?
Hi!
I am trying to follow some examples for deploying trained Tensorflow Lite models from MATLAB to Raspberry Pi. Here are the pre-requisites I am trying to satisfiy:
https://www.mathworks.com/help/deeplearning/ug/prerequisites-for-deep-learning-with-tensorflow-lite-models.html
At the end of this page, there are some instructions on setting some environment variables. I could do as instructed on the host computer, but I am confused how to set the variables on Raspberry Pi. Specifically, I couldn’t find the correct paths for TFLITE_PATH and LD_LIBRARY_PATH. According to the instructions, I should set
TFLITE_PATH: Location of the TensorFlow Lite library directory.
LD_LIBRARY_PATH: Location of the run-time shared library. For example, TFLITE_PATH/lib/tensorflow/lite.
Here is how I installed TFLite on my Raspberry Pi. I used the command "python3 -m pip install tflite-runtime", which seemed to successfully install TFLite. This can be verified when I excuted the following commands on the Pi terminal:
python3
import tflite_runtime
tflite_runtime.__version__
which then shows ‘2.5.0’.
When I executed "python3 -m pip show tflite_runtime", this is what I see:
Name: tflite-runtime
Version: 2.5.0
Summary: TensorFlow Lite is for mobile and embedded devices.
Home-page: https://www.tensorflow.org/lite/
Author: Google, LLC
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /home/pi/.local/lib/python3.7/site-packages
Requires: numpy
Required-by:
I’m not sure if that "site-packages" folder is the correct location for the library. If I set this to be my TFLITE_PATH, there is no such sub-directory as "TFLITE_PATH/lib/tensorflow/lite" which is supposed to be defined as LD_LIBRARY_PATH.
Please let me know if I am missing anything. Thank you!Hi!
I am trying to follow some examples for deploying trained Tensorflow Lite models from MATLAB to Raspberry Pi. Here are the pre-requisites I am trying to satisfiy:
https://www.mathworks.com/help/deeplearning/ug/prerequisites-for-deep-learning-with-tensorflow-lite-models.html
At the end of this page, there are some instructions on setting some environment variables. I could do as instructed on the host computer, but I am confused how to set the variables on Raspberry Pi. Specifically, I couldn’t find the correct paths for TFLITE_PATH and LD_LIBRARY_PATH. According to the instructions, I should set
TFLITE_PATH: Location of the TensorFlow Lite library directory.
LD_LIBRARY_PATH: Location of the run-time shared library. For example, TFLITE_PATH/lib/tensorflow/lite.
Here is how I installed TFLite on my Raspberry Pi. I used the command "python3 -m pip install tflite-runtime", which seemed to successfully install TFLite. This can be verified when I excuted the following commands on the Pi terminal:
python3
import tflite_runtime
tflite_runtime.__version__
which then shows ‘2.5.0’.
When I executed "python3 -m pip show tflite_runtime", this is what I see:
Name: tflite-runtime
Version: 2.5.0
Summary: TensorFlow Lite is for mobile and embedded devices.
Home-page: https://www.tensorflow.org/lite/
Author: Google, LLC
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /home/pi/.local/lib/python3.7/site-packages
Requires: numpy
Required-by:
I’m not sure if that "site-packages" folder is the correct location for the library. If I set this to be my TFLITE_PATH, there is no such sub-directory as "TFLITE_PATH/lib/tensorflow/lite" which is supposed to be defined as LD_LIBRARY_PATH.
Please let me know if I am missing anything. Thank you! Hi!
I am trying to follow some examples for deploying trained Tensorflow Lite models from MATLAB to Raspberry Pi. Here are the pre-requisites I am trying to satisfiy:
https://www.mathworks.com/help/deeplearning/ug/prerequisites-for-deep-learning-with-tensorflow-lite-models.html
At the end of this page, there are some instructions on setting some environment variables. I could do as instructed on the host computer, but I am confused how to set the variables on Raspberry Pi. Specifically, I couldn’t find the correct paths for TFLITE_PATH and LD_LIBRARY_PATH. According to the instructions, I should set
TFLITE_PATH: Location of the TensorFlow Lite library directory.
LD_LIBRARY_PATH: Location of the run-time shared library. For example, TFLITE_PATH/lib/tensorflow/lite.
Here is how I installed TFLite on my Raspberry Pi. I used the command "python3 -m pip install tflite-runtime", which seemed to successfully install TFLite. This can be verified when I excuted the following commands on the Pi terminal:
python3
import tflite_runtime
tflite_runtime.__version__
which then shows ‘2.5.0’.
When I executed "python3 -m pip show tflite_runtime", this is what I see:
Name: tflite-runtime
Version: 2.5.0
Summary: TensorFlow Lite is for mobile and embedded devices.
Home-page: https://www.tensorflow.org/lite/
Author: Google, LLC
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /home/pi/.local/lib/python3.7/site-packages
Requires: numpy
Required-by:
I’m not sure if that "site-packages" folder is the correct location for the library. If I set this to be my TFLITE_PATH, there is no such sub-directory as "TFLITE_PATH/lib/tensorflow/lite" which is supposed to be defined as LD_LIBRARY_PATH.
Please let me know if I am missing anything. Thank you! raspberry pi, tensorflow lite, deployment MATLAB Answers — New Questions
how assign cell to dropdown menu
app.PeriodicityDropDown.Items
ans =
1×4 cell array
{‘Option 1’} {‘Option 2’} {‘Option 3’} {‘Option 4’}
K>> class(tmp)
ans =
‘double’
i try this solution:
K>> app.PeriodicityDropDown.Items={tmp}
‘Items’ must be a 1-by-N cell array of character vectors or a string array.
K>> app.PeriodicityDropDown.Items=num2cell(tmp)
‘Items’ must be a 1-by-N cell array of character vectors or a string array.
how can i assign it?app.PeriodicityDropDown.Items
ans =
1×4 cell array
{‘Option 1’} {‘Option 2’} {‘Option 3’} {‘Option 4’}
K>> class(tmp)
ans =
‘double’
i try this solution:
K>> app.PeriodicityDropDown.Items={tmp}
‘Items’ must be a 1-by-N cell array of character vectors or a string array.
K>> app.PeriodicityDropDown.Items=num2cell(tmp)
‘Items’ must be a 1-by-N cell array of character vectors or a string array.
how can i assign it? app.PeriodicityDropDown.Items
ans =
1×4 cell array
{‘Option 1’} {‘Option 2’} {‘Option 3’} {‘Option 4’}
K>> class(tmp)
ans =
‘double’
i try this solution:
K>> app.PeriodicityDropDown.Items={tmp}
‘Items’ must be a 1-by-N cell array of character vectors or a string array.
K>> app.PeriodicityDropDown.Items=num2cell(tmp)
‘Items’ must be a 1-by-N cell array of character vectors or a string array.
how can i assign it? how assign cell to dropdown menu MATLAB Answers — New Questions
matlab program in 3- piont guassian quadrature to evaluate integral f(x)= sin(�x/10)
n/an/a n/a n/a MATLAB Answers — New Questions
mapping the thrust and torques applied to the quadcopter to the PWM commands (PX4_Autopilot)
Hello,I’m trying to implement a simple Hardware-in-the-Loop (HITL) simulation using PX4 and the UAV Toolbox Support Package for PX4 Autopilots (using PX4 Host Target). Specifically, I’ve customized a different controller for the quadcopter. However, I’m having trouble understanding how to use the actuator_write block. I’ve read the documentation, which states that the input should be between -1 and +1. How can we map the thrust and torques applied to the quadcopter to the commands u? Thanks.Hello,I’m trying to implement a simple Hardware-in-the-Loop (HITL) simulation using PX4 and the UAV Toolbox Support Package for PX4 Autopilots (using PX4 Host Target). Specifically, I’ve customized a different controller for the quadcopter. However, I’m having trouble understanding how to use the actuator_write block. I’ve read the documentation, which states that the input should be between -1 and +1. How can we map the thrust and torques applied to the quadcopter to the commands u? Thanks. Hello,I’m trying to implement a simple Hardware-in-the-Loop (HITL) simulation using PX4 and the UAV Toolbox Support Package for PX4 Autopilots (using PX4 Host Target). Specifically, I’ve customized a different controller for the quadcopter. However, I’m having trouble understanding how to use the actuator_write block. I’ve read the documentation, which states that the input should be between -1 and +1. How can we map the thrust and torques applied to the quadcopter to the commands u? Thanks. px4, uav control MATLAB Answers — New Questions
Mean of 1000 for loop Euler-Maruyama simulations of SDE
Hello,
I’m experimenting with this code adapted from the paper "An Algorithmic Introduction to Numerical Simulation of Stochastic Differential Equations" by Desmond J. Higham. It runs a simulation of an SDE then plots the single simulation. I’m trying to make it so the program runs many such simulations, say 1000, and then plots their mean, so the graph should be more like a smooth line (I am trying to see if it is). Basically I want to take the for loop in this code, run it 1000 times, then get the mean of the 1000 results we get and plot its graph.
I’d appreciate some advice, I’m sure the solution is fairly simple but I haven’t been successful in my attempts.
%EM Euler-Maruyama method on linear SDE
% Discretized Brownian path over [0,1] has dt = 2^(-8).
% Euler-Maruyama uses timestep R*dt.
%randn("state",100)
Xzero = 0; % problem parameters
T = 1;
N = 2^8;
dt = 1/N;
r=1;
G=0.7;
e=0.5;
M=1000;
dW = sqrt(dt)*randn(M,N); % Brownian increments
W = cumsum(dW); % discretized Brownian path
R = 2; Dt = R*dt; L = N/R; % L EM steps of size Dt = R*dt
Xem = zeros(1,L); % preallocate for efficiency
Xtemp = Xzero;
for j = 1:L
Winc = sum(dW(R*(j-1)+1:R*j));
Xtemp = Dt*r*(G-Xtemp) + sqrt((e*Xtemp)*(1-Xtemp))*Winc;
Xem(j) = Xtemp;
end
plot([0:Dt:T],[Xzero,Xem],"r–*"), hold off
xlabel("t","FontSize",12)
ylabel("X","FontSize",16,"Rotation",0,"HorizontalAlignment","right")Hello,
I’m experimenting with this code adapted from the paper "An Algorithmic Introduction to Numerical Simulation of Stochastic Differential Equations" by Desmond J. Higham. It runs a simulation of an SDE then plots the single simulation. I’m trying to make it so the program runs many such simulations, say 1000, and then plots their mean, so the graph should be more like a smooth line (I am trying to see if it is). Basically I want to take the for loop in this code, run it 1000 times, then get the mean of the 1000 results we get and plot its graph.
I’d appreciate some advice, I’m sure the solution is fairly simple but I haven’t been successful in my attempts.
%EM Euler-Maruyama method on linear SDE
% Discretized Brownian path over [0,1] has dt = 2^(-8).
% Euler-Maruyama uses timestep R*dt.
%randn("state",100)
Xzero = 0; % problem parameters
T = 1;
N = 2^8;
dt = 1/N;
r=1;
G=0.7;
e=0.5;
M=1000;
dW = sqrt(dt)*randn(M,N); % Brownian increments
W = cumsum(dW); % discretized Brownian path
R = 2; Dt = R*dt; L = N/R; % L EM steps of size Dt = R*dt
Xem = zeros(1,L); % preallocate for efficiency
Xtemp = Xzero;
for j = 1:L
Winc = sum(dW(R*(j-1)+1:R*j));
Xtemp = Dt*r*(G-Xtemp) + sqrt((e*Xtemp)*(1-Xtemp))*Winc;
Xem(j) = Xtemp;
end
plot([0:Dt:T],[Xzero,Xem],"r–*"), hold off
xlabel("t","FontSize",12)
ylabel("X","FontSize",16,"Rotation",0,"HorizontalAlignment","right") Hello,
I’m experimenting with this code adapted from the paper "An Algorithmic Introduction to Numerical Simulation of Stochastic Differential Equations" by Desmond J. Higham. It runs a simulation of an SDE then plots the single simulation. I’m trying to make it so the program runs many such simulations, say 1000, and then plots their mean, so the graph should be more like a smooth line (I am trying to see if it is). Basically I want to take the for loop in this code, run it 1000 times, then get the mean of the 1000 results we get and plot its graph.
I’d appreciate some advice, I’m sure the solution is fairly simple but I haven’t been successful in my attempts.
%EM Euler-Maruyama method on linear SDE
% Discretized Brownian path over [0,1] has dt = 2^(-8).
% Euler-Maruyama uses timestep R*dt.
%randn("state",100)
Xzero = 0; % problem parameters
T = 1;
N = 2^8;
dt = 1/N;
r=1;
G=0.7;
e=0.5;
M=1000;
dW = sqrt(dt)*randn(M,N); % Brownian increments
W = cumsum(dW); % discretized Brownian path
R = 2; Dt = R*dt; L = N/R; % L EM steps of size Dt = R*dt
Xem = zeros(1,L); % preallocate for efficiency
Xtemp = Xzero;
for j = 1:L
Winc = sum(dW(R*(j-1)+1:R*j));
Xtemp = Dt*r*(G-Xtemp) + sqrt((e*Xtemp)*(1-Xtemp))*Winc;
Xem(j) = Xtemp;
end
plot([0:Dt:T],[Xzero,Xem],"r–*"), hold off
xlabel("t","FontSize",12)
ylabel("X","FontSize",16,"Rotation",0,"HorizontalAlignment","right") for loop, mean, graph MATLAB Answers — New Questions
Does MATLAB still allow for the use of Property Inspector to edit axis labels?
I am attempting to edit the Y-axis labels and ticks in a plot using the Property Inspector, in MATLAB 2023b. I am able to alter the labels and tick marks in the Property Inspector window. However, the changes do not get applied to the figure.
In previous versions of MATLAB, the user changes were applied when the user pushed the Apply and OK buttons in the Edit Axes Ticks window.
Although it appears this topic has been brought up several times, I can’t find a link to a possible resolution to this issue.
Assuming we can still apply updated Axes and Axes Ticks values, using the Property Inspector, does anyone have a link containing this solution?
Thank YouI am attempting to edit the Y-axis labels and ticks in a plot using the Property Inspector, in MATLAB 2023b. I am able to alter the labels and tick marks in the Property Inspector window. However, the changes do not get applied to the figure.
In previous versions of MATLAB, the user changes were applied when the user pushed the Apply and OK buttons in the Edit Axes Ticks window.
Although it appears this topic has been brought up several times, I can’t find a link to a possible resolution to this issue.
Assuming we can still apply updated Axes and Axes Ticks values, using the Property Inspector, does anyone have a link containing this solution?
Thank You I am attempting to edit the Y-axis labels and ticks in a plot using the Property Inspector, in MATLAB 2023b. I am able to alter the labels and tick marks in the Property Inspector window. However, the changes do not get applied to the figure.
In previous versions of MATLAB, the user changes were applied when the user pushed the Apply and OK buttons in the Edit Axes Ticks window.
Although it appears this topic has been brought up several times, I can’t find a link to a possible resolution to this issue.
Assuming we can still apply updated Axes and Axes Ticks values, using the Property Inspector, does anyone have a link containing this solution?
Thank You property inspector MATLAB Answers — New Questions
Why simulink double click or block properties respond slow
I’ve Matlab R2021b version that is installed on a higher end laptop now and the respond in Simulink to add new block or to open properties of a block is slow. The lower end laptops that I used Simulink on before responded as soon as I double click it.I’ve Matlab R2021b version that is installed on a higher end laptop now and the respond in Simulink to add new block or to open properties of a block is slow. The lower end laptops that I used Simulink on before responded as soon as I double click it. I’ve Matlab R2021b version that is installed on a higher end laptop now and the respond in Simulink to add new block or to open properties of a block is slow. The lower end laptops that I used Simulink on before responded as soon as I double click it. simulink, blocks, double-click MATLAB Answers — New Questions
how to insert image to gui?
i want to insert image to gui.i created axes and tried to insert.imaged is loaded,but error is ,imaged not loading inside the axes og gui o/p.it opening as separate image window.help neededi want to insert image to gui.i created axes and tried to insert.imaged is loaded,but error is ,imaged not loading inside the axes og gui o/p.it opening as separate image window.help needed i want to insert image to gui.i created axes and tried to insert.imaged is loaded,but error is ,imaged not loading inside the axes og gui o/p.it opening as separate image window.help needed gui, image, imread, imshow MATLAB Answers — New Questions
mass calculation error when computing rocket trajectory
Hello,
I have project, where I am trying to compute the trajectory of a rocket and also compute when to release a smaller rocket. The code works in general and uses Rungekutta. The main issue is computing the fuelconsumtion/remaining fuel mass. The issue seems that the mass resets after some time and I am not sure the fuel consumtion or fuel mass is computed in the correct manner.
Any help is greatly appriciatedHello,
I have project, where I am trying to compute the trajectory of a rocket and also compute when to release a smaller rocket. The code works in general and uses Rungekutta. The main issue is computing the fuelconsumtion/remaining fuel mass. The issue seems that the mass resets after some time and I am not sure the fuel consumtion or fuel mass is computed in the correct manner.
Any help is greatly appriciated Hello,
I have project, where I am trying to compute the trajectory of a rocket and also compute when to release a smaller rocket. The code works in general and uses Rungekutta. The main issue is computing the fuelconsumtion/remaining fuel mass. The issue seems that the mass resets after some time and I am not sure the fuel consumtion or fuel mass is computed in the correct manner.
Any help is greatly appriciated runge-kutta, rocket trajectory, mass computation, ode MATLAB Answers — New Questions
calculate with Twiddle factor
Does anybody knows how to calculate the Twiddle Factors?
For example: for n=4 you have to do the calculate Wn= e^(-j*2*π)/n and ypu have to do it for a table 4×4.
table looks like..
<</matlabcentral/answers/uploaded_files/44456/%CE%A7%CF%89%CF%81%CE%AF%CF%82%20%CF%84%CE%AF%CF%84%CE%BB%CE%BF.jpg>>
the second is the table after calculate the 4×4
and i need this for calculate twiddle factors for n=8,16,24…Does anybody knows how to calculate the Twiddle Factors?
For example: for n=4 you have to do the calculate Wn= e^(-j*2*π)/n and ypu have to do it for a table 4×4.
table looks like..
<</matlabcentral/answers/uploaded_files/44456/%CE%A7%CF%89%CF%81%CE%AF%CF%82%20%CF%84%CE%AF%CF%84%CE%BB%CE%BF.jpg>>
the second is the table after calculate the 4×4
and i need this for calculate twiddle factors for n=8,16,24… Does anybody knows how to calculate the Twiddle Factors?
For example: for n=4 you have to do the calculate Wn= e^(-j*2*π)/n and ypu have to do it for a table 4×4.
table looks like..
<</matlabcentral/answers/uploaded_files/44456/%CE%A7%CF%89%CF%81%CE%AF%CF%82%20%CF%84%CE%AF%CF%84%CE%BB%CE%BF.jpg>>
the second is the table after calculate the 4×4
and i need this for calculate twiddle factors for n=8,16,24… twiddle factor, calculate MATLAB Answers — New Questions
When I use attentionLayer to input QKV, Matlab tells me error
I use Matlab 2024b realase to construct lstm-attention-lstm network, the key and value come from the output of the lstm1, and the query comes from lstm2’s output, however when I make this, the Matlab tells me that there is a net circle error. How can I achieve me goal whithout error. Thank you very much.
Here is my code and layers:
net = dlnetwork;
layers = [
sequenceInputLayer(InputChannels,Name="input")
lstmLayer(hidden_num_lstm1, ‘OutputMode’, ‘sequence’, Name=’lstm_encoder’)
dropoutLayer(0.2, Name=’dropout_1′)
layerNormalizationLayer(Name=’batchnormal_1′)
fullyConnectedLayer(AttentionChannels, Name="key") % Key
attentionLayer(NumHeads, Name="cross-attention")
layerNormalizationLayer
lstmLayer(hidden_num_lstm2, ‘OutputMode’, ‘sequence’, Name=’lstm_decoder’)
dropoutLayer(0.2, Name=’dropout_2′)
layerNormalizationLayer(Name=’batchnormal_2′)
fullyConnectedLayer(64, Name=’fc’)
fullyConnectedLayer(OutputChannels, Name=’fc_out’)
];
net = addLayers(net,layers);
net = connectLayers(net,’key’,’cross-attention/key’);
net = disconnectLayers(net,’key’,’cross-attention/query’);
plot(net);
layers = [
fullyConnectedLayer(AttentionChannels, Name="value") % Value
];
net = addLayers(net,layers);
net = connectLayers(net,’batchnormal_1′,’value’);
net = connectLayers(net,’value’,’cross-attention/value’);
plot(net);
layers = [
fullyConnectedLayer(AttentionChannels, Name="query") % Query
];
net = addLayers(net,layers);
net = connectLayers(net,’lstm_decoder’,’query’);
net = connectLayers(net,’query’,’cross-attention/query’);
plot(net);I use Matlab 2024b realase to construct lstm-attention-lstm network, the key and value come from the output of the lstm1, and the query comes from lstm2’s output, however when I make this, the Matlab tells me that there is a net circle error. How can I achieve me goal whithout error. Thank you very much.
Here is my code and layers:
net = dlnetwork;
layers = [
sequenceInputLayer(InputChannels,Name="input")
lstmLayer(hidden_num_lstm1, ‘OutputMode’, ‘sequence’, Name=’lstm_encoder’)
dropoutLayer(0.2, Name=’dropout_1′)
layerNormalizationLayer(Name=’batchnormal_1′)
fullyConnectedLayer(AttentionChannels, Name="key") % Key
attentionLayer(NumHeads, Name="cross-attention")
layerNormalizationLayer
lstmLayer(hidden_num_lstm2, ‘OutputMode’, ‘sequence’, Name=’lstm_decoder’)
dropoutLayer(0.2, Name=’dropout_2′)
layerNormalizationLayer(Name=’batchnormal_2′)
fullyConnectedLayer(64, Name=’fc’)
fullyConnectedLayer(OutputChannels, Name=’fc_out’)
];
net = addLayers(net,layers);
net = connectLayers(net,’key’,’cross-attention/key’);
net = disconnectLayers(net,’key’,’cross-attention/query’);
plot(net);
layers = [
fullyConnectedLayer(AttentionChannels, Name="value") % Value
];
net = addLayers(net,layers);
net = connectLayers(net,’batchnormal_1′,’value’);
net = connectLayers(net,’value’,’cross-attention/value’);
plot(net);
layers = [
fullyConnectedLayer(AttentionChannels, Name="query") % Query
];
net = addLayers(net,layers);
net = connectLayers(net,’lstm_decoder’,’query’);
net = connectLayers(net,’query’,’cross-attention/query’);
plot(net); I use Matlab 2024b realase to construct lstm-attention-lstm network, the key and value come from the output of the lstm1, and the query comes from lstm2’s output, however when I make this, the Matlab tells me that there is a net circle error. How can I achieve me goal whithout error. Thank you very much.
Here is my code and layers:
net = dlnetwork;
layers = [
sequenceInputLayer(InputChannels,Name="input")
lstmLayer(hidden_num_lstm1, ‘OutputMode’, ‘sequence’, Name=’lstm_encoder’)
dropoutLayer(0.2, Name=’dropout_1′)
layerNormalizationLayer(Name=’batchnormal_1′)
fullyConnectedLayer(AttentionChannels, Name="key") % Key
attentionLayer(NumHeads, Name="cross-attention")
layerNormalizationLayer
lstmLayer(hidden_num_lstm2, ‘OutputMode’, ‘sequence’, Name=’lstm_decoder’)
dropoutLayer(0.2, Name=’dropout_2′)
layerNormalizationLayer(Name=’batchnormal_2′)
fullyConnectedLayer(64, Name=’fc’)
fullyConnectedLayer(OutputChannels, Name=’fc_out’)
];
net = addLayers(net,layers);
net = connectLayers(net,’key’,’cross-attention/key’);
net = disconnectLayers(net,’key’,’cross-attention/query’);
plot(net);
layers = [
fullyConnectedLayer(AttentionChannels, Name="value") % Value
];
net = addLayers(net,layers);
net = connectLayers(net,’batchnormal_1′,’value’);
net = connectLayers(net,’value’,’cross-attention/value’);
plot(net);
layers = [
fullyConnectedLayer(AttentionChannels, Name="query") % Query
];
net = addLayers(net,layers);
net = connectLayers(net,’lstm_decoder’,’query’);
net = connectLayers(net,’query’,’cross-attention/query’);
plot(net); attentionlayer, network, deeplearning MATLAB Answers — New Questions
Pretrained deep net (Vgg-F)
I have downloaded a pretrained model Vgg-F from the site (https://www.vlfeat.org/matconvnet/pretrained/)
When i try to pass my image without training i got the following error
net = load(‘imagenet-vgg-f.mat’) ;
layer =’fc8′
feat = activations(net,img,layer,’OutputAs’,’columns’);
Check for missing argument or incorrect argument data type in call to function ‘activations’.
Error in (line 81)
feat = activations(net,img,layer,’OutputAs’,’columns’);
Please how to solve the problem?I have downloaded a pretrained model Vgg-F from the site (https://www.vlfeat.org/matconvnet/pretrained/)
When i try to pass my image without training i got the following error
net = load(‘imagenet-vgg-f.mat’) ;
layer =’fc8′
feat = activations(net,img,layer,’OutputAs’,’columns’);
Check for missing argument or incorrect argument data type in call to function ‘activations’.
Error in (line 81)
feat = activations(net,img,layer,’OutputAs’,’columns’);
Please how to solve the problem? I have downloaded a pretrained model Vgg-F from the site (https://www.vlfeat.org/matconvnet/pretrained/)
When i try to pass my image without training i got the following error
net = load(‘imagenet-vgg-f.mat’) ;
layer =’fc8′
feat = activations(net,img,layer,’OutputAs’,’columns’);
Check for missing argument or incorrect argument data type in call to function ‘activations’.
Error in (line 81)
feat = activations(net,img,layer,’OutputAs’,’columns’);
Please how to solve the problem? pretrained deep net, vgg-f, activations MATLAB Answers — New Questions
how to run simulink and matlab project with python? for example : video processing fr(om matlab will used in python
i dont have code yeti dont have code yet i dont have code yet video processing MATLAB Answers — New Questions
Matlab parpool gives me 4 workers on Azure VM instead of 8 workers
I just deployed Matlab 2024b on Azure VM, with 8gb vCPU, 32gb RAM. However when i start the parpool with
% Start a parallel pool
parpool(‘local’ );
parfor linearIdx = 1:totalCombinations
…
end
it runs with 4 workers whereas i would expect 8 workers since i have 8 vCPUS.
also parcluster(‘local’) gives me
Local Cluster
Properties:
Profile: Processes
Modified: false
Host: matlabvm
NumWorkers: 4
NumThreads: 1
JobStorageLocation: /home/ubuntu/.matlab/local_cluster_jobs/R2024b
RequiresOnlineLicensing: false
PreferredPoolNumWorkers: Inf
Associated Jobs:
Number Pending: 0
Number Queued: 0
Number Running: 1
Number Finished: 0
Please note my Matlab 2024b licence is a Trial version. Could this be the case? ThanksI just deployed Matlab 2024b on Azure VM, with 8gb vCPU, 32gb RAM. However when i start the parpool with
% Start a parallel pool
parpool(‘local’ );
parfor linearIdx = 1:totalCombinations
…
end
it runs with 4 workers whereas i would expect 8 workers since i have 8 vCPUS.
also parcluster(‘local’) gives me
Local Cluster
Properties:
Profile: Processes
Modified: false
Host: matlabvm
NumWorkers: 4
NumThreads: 1
JobStorageLocation: /home/ubuntu/.matlab/local_cluster_jobs/R2024b
RequiresOnlineLicensing: false
PreferredPoolNumWorkers: Inf
Associated Jobs:
Number Pending: 0
Number Queued: 0
Number Running: 1
Number Finished: 0
Please note my Matlab 2024b licence is a Trial version. Could this be the case? Thanks I just deployed Matlab 2024b on Azure VM, with 8gb vCPU, 32gb RAM. However when i start the parpool with
% Start a parallel pool
parpool(‘local’ );
parfor linearIdx = 1:totalCombinations
…
end
it runs with 4 workers whereas i would expect 8 workers since i have 8 vCPUS.
also parcluster(‘local’) gives me
Local Cluster
Properties:
Profile: Processes
Modified: false
Host: matlabvm
NumWorkers: 4
NumThreads: 1
JobStorageLocation: /home/ubuntu/.matlab/local_cluster_jobs/R2024b
RequiresOnlineLicensing: false
PreferredPoolNumWorkers: Inf
Associated Jobs:
Number Pending: 0
Number Queued: 0
Number Running: 1
Number Finished: 0
Please note my Matlab 2024b licence is a Trial version. Could this be the case? Thanks parallel computing, parfor, loop, parallel computing toolbox MATLAB Answers — New Questions
My parallel worker fall back to 3 workers when running at 4 workers
I was running a my code using parpool(4) which using 4 workers. However, I noticed after the execution of my code(having each worker writing to their own files), the workers falls back to 3. What could be the reason behind this?I was running a my code using parpool(4) which using 4 workers. However, I noticed after the execution of my code(having each worker writing to their own files), the workers falls back to 3. What could be the reason behind this? I was running a my code using parpool(4) which using 4 workers. However, I noticed after the execution of my code(having each worker writing to their own files), the workers falls back to 3. What could be the reason behind this? parallel computing toolbox, parfor, parpool MATLAB Answers — New Questions
Can we generate C++ code from Simulink models from bash or PowerShell command line?
Can we generate C++ code from Simulink models from bash or PowerShell?
I am a beginner with Matlab and Simulink, I manage the build system for my company, we are trying to integrate a build step that will look at all the Simulink models and generates code for them. In order to achieve that, we need an interface to Simulink Coder from the command line and not inside Matlab or it’s add on applications.
Is this interface exposed ? and would this be a possibility ?Can we generate C++ code from Simulink models from bash or PowerShell?
I am a beginner with Matlab and Simulink, I manage the build system for my company, we are trying to integrate a build step that will look at all the Simulink models and generates code for them. In order to achieve that, we need an interface to Simulink Coder from the command line and not inside Matlab or it’s add on applications.
Is this interface exposed ? and would this be a possibility ? Can we generate C++ code from Simulink models from bash or PowerShell?
I am a beginner with Matlab and Simulink, I manage the build system for my company, we are trying to integrate a build step that will look at all the Simulink models and generates code for them. In order to achieve that, we need an interface to Simulink Coder from the command line and not inside Matlab or it’s add on applications.
Is this interface exposed ? and would this be a possibility ? simulink, matlab coder, code generation MATLAB Answers — New Questions