Tag Archives: matlab
How to plot a string signal/array?
Hi all,
In Simulink, I’m using String Signals to represent internal states for my systems. For example:
mySignal is a string signal, and not a numeric one. I log it into the base workspace inside the simout variable, and I also send it to the Simulation Data Inspector.
Inside the Simulation Data Inspector, this string signal is neatly displayed, like this :
The string values are displayed as colored patches, evolving with the simulation time.
This visualization method for string signals is great, but I can’t find a way to do something similar in MATLAB. Once my string signal is inside a base workspace variable, I try to plot it just like a regular signal, but it doesn’t work:
>> simout
simout =
struct with fields:
time: [1001×1 double]
signals: [1×1 struct]
blockName: ‘plot_string_signals/To Workspace’
>> simout.signals
ans =
struct with fields:
values: [1001×1 string]
dimensions: 1
label: ‘mySignal’
>> plot(simout.time, simout.signals.values)
Error using plot
Invalid data argument.
So my question is: how to plot a string datatype signal/array in MATLAB? Is there a dedicated plotting function for this use case that I don’t know ? I expected the plot function to provide the same kind of graph as the Simulation Data Inspector, but was disappointed.
(I’m using MATLAB 22b Update 8)
Thanks,
SeiganHi all,
In Simulink, I’m using String Signals to represent internal states for my systems. For example:
mySignal is a string signal, and not a numeric one. I log it into the base workspace inside the simout variable, and I also send it to the Simulation Data Inspector.
Inside the Simulation Data Inspector, this string signal is neatly displayed, like this :
The string values are displayed as colored patches, evolving with the simulation time.
This visualization method for string signals is great, but I can’t find a way to do something similar in MATLAB. Once my string signal is inside a base workspace variable, I try to plot it just like a regular signal, but it doesn’t work:
>> simout
simout =
struct with fields:
time: [1001×1 double]
signals: [1×1 struct]
blockName: ‘plot_string_signals/To Workspace’
>> simout.signals
ans =
struct with fields:
values: [1001×1 string]
dimensions: 1
label: ‘mySignal’
>> plot(simout.time, simout.signals.values)
Error using plot
Invalid data argument.
So my question is: how to plot a string datatype signal/array in MATLAB? Is there a dedicated plotting function for this use case that I don’t know ? I expected the plot function to provide the same kind of graph as the Simulation Data Inspector, but was disappointed.
(I’m using MATLAB 22b Update 8)
Thanks,
Seigan Hi all,
In Simulink, I’m using String Signals to represent internal states for my systems. For example:
mySignal is a string signal, and not a numeric one. I log it into the base workspace inside the simout variable, and I also send it to the Simulation Data Inspector.
Inside the Simulation Data Inspector, this string signal is neatly displayed, like this :
The string values are displayed as colored patches, evolving with the simulation time.
This visualization method for string signals is great, but I can’t find a way to do something similar in MATLAB. Once my string signal is inside a base workspace variable, I try to plot it just like a regular signal, but it doesn’t work:
>> simout
simout =
struct with fields:
time: [1001×1 double]
signals: [1×1 struct]
blockName: ‘plot_string_signals/To Workspace’
>> simout.signals
ans =
struct with fields:
values: [1001×1 string]
dimensions: 1
label: ‘mySignal’
>> plot(simout.time, simout.signals.values)
Error using plot
Invalid data argument.
So my question is: how to plot a string datatype signal/array in MATLAB? Is there a dedicated plotting function for this use case that I don’t know ? I expected the plot function to provide the same kind of graph as the Simulation Data Inspector, but was disappointed.
(I’m using MATLAB 22b Update 8)
Thanks,
Seigan plot, string MATLAB Answers — New Questions
How to connect ESP32-C3-ZERO to Simulink
Dear Users.
I hope that you are doing well,
I have one simple question on how to use ESP32-C3-ZERO on simulink is there any idea beside of using waijung?
My application is just to use wifi to read an analog signal.Dear Users.
I hope that you are doing well,
I have one simple question on how to use ESP32-C3-ZERO on simulink is there any idea beside of using waijung?
My application is just to use wifi to read an analog signal. Dear Users.
I hope that you are doing well,
I have one simple question on how to use ESP32-C3-ZERO on simulink is there any idea beside of using waijung?
My application is just to use wifi to read an analog signal. simulink, real-time-monitoring, esp32, arduino, signal MATLAB Answers — New Questions
Issue in creation of test harness of a Simulink state in stateflow or creation of harness of a subsystem present in simulink state of stateflow.
Hello,
I wish to create a harness of a simulink state present in a stateflow.I am not getting the option of ‘Test Harness’,when right clicked on state
Also i tried to create a harness of a subsystem present in that simulink state but got the following error
So is there any other way to create test harness of such simulink state or subsystem present in that simulink state?
If not then can you suggest how to test such state by creating test hanress?Hello,
I wish to create a harness of a simulink state present in a stateflow.I am not getting the option of ‘Test Harness’,when right clicked on state
Also i tried to create a harness of a subsystem present in that simulink state but got the following error
So is there any other way to create test harness of such simulink state or subsystem present in that simulink state?
If not then can you suggest how to test such state by creating test hanress? Hello,
I wish to create a harness of a simulink state present in a stateflow.I am not getting the option of ‘Test Harness’,when right clicked on state
Also i tried to create a harness of a subsystem present in that simulink state but got the following error
So is there any other way to create test harness of such simulink state or subsystem present in that simulink state?
If not then can you suggest how to test such state by creating test hanress? simulink, stateflow, simulinkstate, modelinloop, testharness, harness, error, states MATLAB Answers — New Questions
mean function gives an error but not median
I am trying to calculate mean, median and 90% percentile of arrays. Median and prctile work fine but mean gives an error message:
Array indices must be positive integers or logical values.
Teh error comes from Averted_Deaths_Array(ij,1) = mean(Averted_Deaths(ij,:)); in the following code.
The code is simple.
TotalDeathsArray = rand(12,2500);
% Calculate Averted cases
for i=1:2500
%2: PCV13 1+1, 3: PCV15 2+1, 4: PCV15 1+1
% 1+1
Averted_Deaths(1,i) = TotalDeathsArray(2,i) – TotalDeathsArray(4,i);
Averted_Deaths(2,i) = TotalDeathsArray(6,i) – TotalDeathsArray(8,i);
Averted_Deaths(3,i) = TotalDeathsArray(10,i) – TotalDeathsArray(12,i);
% 2+1
Averted_Deaths(4,i) = TotalDeathsArray(2,i) – TotalDeathsArray(3,i);
Averted_Deaths(5,i) = TotalDeathsArray(6,i) – TotalDeathsArray(7,i);
Averted_Deaths(6,i) = TotalDeathsArray(10,i) – TotalDeathsArray(11,i);
end
Averted_Deaths_Array = zeros(6,3);
for ij=1:6 % Averted QALY
%Averted QALY when changing with New 1+1
Averted_Deaths_Array(ij,1) = mean(Averted_Deaths(ij,:));
Averted_Deaths_Array(ij,2) = median(Averted_Deaths(ij,:));
Averted_Deaths_Array(ij,3) = prctile(Averted_Deaths(ij,:),90);
endI am trying to calculate mean, median and 90% percentile of arrays. Median and prctile work fine but mean gives an error message:
Array indices must be positive integers or logical values.
Teh error comes from Averted_Deaths_Array(ij,1) = mean(Averted_Deaths(ij,:)); in the following code.
The code is simple.
TotalDeathsArray = rand(12,2500);
% Calculate Averted cases
for i=1:2500
%2: PCV13 1+1, 3: PCV15 2+1, 4: PCV15 1+1
% 1+1
Averted_Deaths(1,i) = TotalDeathsArray(2,i) – TotalDeathsArray(4,i);
Averted_Deaths(2,i) = TotalDeathsArray(6,i) – TotalDeathsArray(8,i);
Averted_Deaths(3,i) = TotalDeathsArray(10,i) – TotalDeathsArray(12,i);
% 2+1
Averted_Deaths(4,i) = TotalDeathsArray(2,i) – TotalDeathsArray(3,i);
Averted_Deaths(5,i) = TotalDeathsArray(6,i) – TotalDeathsArray(7,i);
Averted_Deaths(6,i) = TotalDeathsArray(10,i) – TotalDeathsArray(11,i);
end
Averted_Deaths_Array = zeros(6,3);
for ij=1:6 % Averted QALY
%Averted QALY when changing with New 1+1
Averted_Deaths_Array(ij,1) = mean(Averted_Deaths(ij,:));
Averted_Deaths_Array(ij,2) = median(Averted_Deaths(ij,:));
Averted_Deaths_Array(ij,3) = prctile(Averted_Deaths(ij,:),90);
end I am trying to calculate mean, median and 90% percentile of arrays. Median and prctile work fine but mean gives an error message:
Array indices must be positive integers or logical values.
Teh error comes from Averted_Deaths_Array(ij,1) = mean(Averted_Deaths(ij,:)); in the following code.
The code is simple.
TotalDeathsArray = rand(12,2500);
% Calculate Averted cases
for i=1:2500
%2: PCV13 1+1, 3: PCV15 2+1, 4: PCV15 1+1
% 1+1
Averted_Deaths(1,i) = TotalDeathsArray(2,i) – TotalDeathsArray(4,i);
Averted_Deaths(2,i) = TotalDeathsArray(6,i) – TotalDeathsArray(8,i);
Averted_Deaths(3,i) = TotalDeathsArray(10,i) – TotalDeathsArray(12,i);
% 2+1
Averted_Deaths(4,i) = TotalDeathsArray(2,i) – TotalDeathsArray(3,i);
Averted_Deaths(5,i) = TotalDeathsArray(6,i) – TotalDeathsArray(7,i);
Averted_Deaths(6,i) = TotalDeathsArray(10,i) – TotalDeathsArray(11,i);
end
Averted_Deaths_Array = zeros(6,3);
for ij=1:6 % Averted QALY
%Averted QALY when changing with New 1+1
Averted_Deaths_Array(ij,1) = mean(Averted_Deaths(ij,:));
Averted_Deaths_Array(ij,2) = median(Averted_Deaths(ij,:));
Averted_Deaths_Array(ij,3) = prctile(Averted_Deaths(ij,:),90);
end mean function error MATLAB Answers — New Questions
Why is the torque in the torque sensor converging to zero
I’m doing a simulation using the pmsm library and switching elements. I want to know why 0 comes out in the trq scope. 1000 rpm is inputted at a fixed rate using an internal velocity source, and the three-phase current from the switching is outputted normally. The control part id iq is indicated as 0 100, and the id iq calculated from the three phases is also 0 100. How can I solve the problem that the torque converges to zero.I’m doing a simulation using the pmsm library and switching elements. I want to know why 0 comes out in the trq scope. 1000 rpm is inputted at a fixed rate using an internal velocity source, and the three-phase current from the switching is outputted normally. The control part id iq is indicated as 0 100, and the id iq calculated from the three phases is also 0 100. How can I solve the problem that the torque converges to zero. I’m doing a simulation using the pmsm library and switching elements. I want to know why 0 comes out in the trq scope. 1000 rpm is inputted at a fixed rate using an internal velocity source, and the three-phase current from the switching is outputted normally. The control part id iq is indicated as 0 100, and the id iq calculated from the three phases is also 0 100. How can I solve the problem that the torque converges to zero. pmsm MATLAB Answers — New Questions
Hello, can MATLAB solve equations like the one below? I mean, can MATLAB find the conditions for z that satisfy this relationship, instead of just numerical solutions?
Post Content Post Content equation, mathematical MATLAB Answers — New Questions
Simulating on-grid three-phase inverter with SVPWM, but the alpha beta components diverge so much
I am simulating for on grid three-phase inverter using PI and PR(seperately control) using SVPWM, this figure aboce is the SVPWM reference signal, which are completely wrong. Somehow the alpha beta component diverge so much from what is intended. what could be the main problem of this? The carrier frequency is 10kHz, and i cant figure out the amplitude because the values kept on diverging and it doesnt show any steadiness
I also tried to switch my own SVPWM design with matlab’s pwm generator and it worked perfectly, I know using the pwm generator is the easier choice, but i want to implement my own SVPWM approach.
This is the DQ component from the PI controller, just before entering into the PWM block, likewise the alpha beta component is also affected by the divergence.
Below is the intended shape of the reference signal for SVPWM, i obtained this from using pure sine waves as the input for the SVPWM, however for an actually inverter, i must use the vref from the PI controller as the input of SVPWMI am simulating for on grid three-phase inverter using PI and PR(seperately control) using SVPWM, this figure aboce is the SVPWM reference signal, which are completely wrong. Somehow the alpha beta component diverge so much from what is intended. what could be the main problem of this? The carrier frequency is 10kHz, and i cant figure out the amplitude because the values kept on diverging and it doesnt show any steadiness
I also tried to switch my own SVPWM design with matlab’s pwm generator and it worked perfectly, I know using the pwm generator is the easier choice, but i want to implement my own SVPWM approach.
This is the DQ component from the PI controller, just before entering into the PWM block, likewise the alpha beta component is also affected by the divergence.
Below is the intended shape of the reference signal for SVPWM, i obtained this from using pure sine waves as the input for the SVPWM, however for an actually inverter, i must use the vref from the PI controller as the input of SVPWM I am simulating for on grid three-phase inverter using PI and PR(seperately control) using SVPWM, this figure aboce is the SVPWM reference signal, which are completely wrong. Somehow the alpha beta component diverge so much from what is intended. what could be the main problem of this? The carrier frequency is 10kHz, and i cant figure out the amplitude because the values kept on diverging and it doesnt show any steadiness
I also tried to switch my own SVPWM design with matlab’s pwm generator and it worked perfectly, I know using the pwm generator is the easier choice, but i want to implement my own SVPWM approach.
This is the DQ component from the PI controller, just before entering into the PWM block, likewise the alpha beta component is also affected by the divergence.
Below is the intended shape of the reference signal for SVPWM, i obtained this from using pure sine waves as the input for the SVPWM, however for an actually inverter, i must use the vref from the PI controller as the input of SVPWM pwm, pulse width modulation, svpwm, inverter, on-grid inverter, simulink, signal, signal processing MATLAB Answers — New Questions
how to extract SIFT features from rgb image in matlab
Hello
I want to extract feature from a color image using SIFT descriptor.
I do not want to convert the image to grayscale and then extract SIFT features.
I want to directly SIFT features extracted from a color image. because color information is important for me.Hello
I want to extract feature from a color image using SIFT descriptor.
I do not want to convert the image to grayscale and then extract SIFT features.
I want to directly SIFT features extracted from a color image. because color information is important for me. Hello
I want to extract feature from a color image using SIFT descriptor.
I do not want to convert the image to grayscale and then extract SIFT features.
I want to directly SIFT features extracted from a color image. because color information is important for me. sift MATLAB Answers — New Questions
How can convert .wav file to .mat file ?
Hello,
I am trying to covert .w to .mat file
and I should to using it in my program
Help me plezzzzzzz :(Hello,
I am trying to covert .w to .mat file
and I should to using it in my program
Help me plezzzzzzz 🙁 Hello,
I am trying to covert .w to .mat file
and I should to using it in my program
Help me plezzzzzzz 🙁 how can convert .wav file to .mat file ? MATLAB Answers — New Questions
Which versions of Vivado are supported with which release of HDL Coder?
I would like to use HDL Coder and its HDL Workflow Advisor to automate the programming of my Xilinx (now AMD) FPGA. For this, I need to install Vivado Design Suite as synthesis tool. Could you tell me which versions of Vivado are compatible with which releases of MATLAB/HDL Coder?I would like to use HDL Coder and its HDL Workflow Advisor to automate the programming of my Xilinx (now AMD) FPGA. For this, I need to install Vivado Design Suite as synthesis tool. Could you tell me which versions of Vivado are compatible with which releases of MATLAB/HDL Coder? I would like to use HDL Coder and its HDL Workflow Advisor to automate the programming of my Xilinx (now AMD) FPGA. For this, I need to install Vivado Design Suite as synthesis tool. Could you tell me which versions of Vivado are compatible with which releases of MATLAB/HDL Coder? xilinx, vivado, synthesis, hdl, hdl-coder, xilinx-vivado, amd MATLAB Answers — New Questions
Black horizontal patches in the plot
I am plottting a simple sst difference plot. My lon data is in the range -180 to 180. I have converted it to 0 to 360. After plotting I am geeting these black patches (attached).
clear
clc
% Define the file paths for WeakTEJYears
WeakTEJYears = {
‘F:SST_MA1979.nc’
‘F:SST_MA1983.nc’
‘F:SST_MA1987.nc’
‘F:SST_MA1997.nc’
‘F:SST_MA2002.nc’
‘F:SST_MA2015.nc’
‘F:SST_MA2023.nc’
};
% Define the file paths for StrongTEJYears
StrongTEJYears = {
‘F:SST_MA1985.nc’
‘F:SST_MA1988.nc’
‘F:SST_MA1999.nc’
‘F:SST_MA2009.nc’
‘F:SST_MA2013.nc’
};
% Initialize variables to store the sum of SST data
sst_sum_weak = 0;
sst_sum_strong = 0;
num_weak_files = length(WeakTEJYears);
num_strong_files = length(StrongTEJYears);
lat_min = -25;
lat_max = 70;
lon_min = 0;
lon_max = 360;
for i = 1:num_weak_files
ncfile = WeakTEJYears{i};
latitude = ncread(ncfile, ‘latitude’);
longitude = ncread(ncfile, ‘longitude’);
longitude(longitude < 0) = longitude(longitude < 0) + 360;
[longitude, sort_idx] = sort(longitude);
sst = ncread(ncfile, ‘sst’);
sst_sorted = sst(sort_idx, :, :); % Re-sort SST data according to longitude sorting
lat_idx = find(latitude >= lat_min & latitude <= lat_max);
lon_idx = find(longitude >= lon_min & longitude <= lon_max);
sst_region = sst_sorted(lon_idx, lat_idx, :);
sst_sum_weak = sst_sum_weak + mean(sst_region, 3); % Mean over time
end
for i = 1:num_strong_files
ncfile = StrongTEJYears{i};
latitude = ncread(ncfile, ‘latitude’);
longitude = ncread(ncfile, ‘longitude’);
longitude(longitude < 0) = longitude(longitude < 0) + 360;
[longitude, sort_idx] = sort(longitude);
sst = ncread(ncfile, ‘sst’);
sst_sorted = sst(sort_idx, :, :);
lat_idx = find(latitude >= lat_min & latitude <= lat_max);
lon_idx = find(longitude >= lon_min & longitude <= lon_max);
sst_region = sst_sorted(lon_idx, lat_idx, :);
sst_sum_strong = sst_sum_strong + mean(sst_region, 3); % Mean over time
end
sst_avg_weak = sst_sum_weak / num_weak_files;
sst_avg_strong = sst_sum_strong / num_strong_files;
sst_diff = sst_avg_strong – sst_avg_weak;
figure;
[lon_mesh, lat_mesh] = meshgrid(longitude(lon_idx), latitude(lat_idx));
contourf(lon_mesh, lat_mesh, sst_diff’, 20, ‘EdgeColor’, ‘none’);
colormap jet;
colorbar;
caxis([-2, 2]);
c.Label.String = ‘Temperature (K)’;
c.Label.FontSize = 18;
c.Label.FontWeight = ‘bold’;
coast = load(‘coastlines’);
coastlon = coast.coastlon;
coastlat = coast.coastlat;
coastlon(coastlon < 0) = coastlon(coastlon < 0) + 360;
hold on;
plot(coastlon, coastlat, ‘k’, ‘LineWidth’, 1.5);
xlim([lon_min, lon_max]);
ylim([lat_min, lat_max]);
title(‘Difference: Strong – Weak TEJ Average SST’, ‘FontSize’, 14);I am plottting a simple sst difference plot. My lon data is in the range -180 to 180. I have converted it to 0 to 360. After plotting I am geeting these black patches (attached).
clear
clc
% Define the file paths for WeakTEJYears
WeakTEJYears = {
‘F:SST_MA1979.nc’
‘F:SST_MA1983.nc’
‘F:SST_MA1987.nc’
‘F:SST_MA1997.nc’
‘F:SST_MA2002.nc’
‘F:SST_MA2015.nc’
‘F:SST_MA2023.nc’
};
% Define the file paths for StrongTEJYears
StrongTEJYears = {
‘F:SST_MA1985.nc’
‘F:SST_MA1988.nc’
‘F:SST_MA1999.nc’
‘F:SST_MA2009.nc’
‘F:SST_MA2013.nc’
};
% Initialize variables to store the sum of SST data
sst_sum_weak = 0;
sst_sum_strong = 0;
num_weak_files = length(WeakTEJYears);
num_strong_files = length(StrongTEJYears);
lat_min = -25;
lat_max = 70;
lon_min = 0;
lon_max = 360;
for i = 1:num_weak_files
ncfile = WeakTEJYears{i};
latitude = ncread(ncfile, ‘latitude’);
longitude = ncread(ncfile, ‘longitude’);
longitude(longitude < 0) = longitude(longitude < 0) + 360;
[longitude, sort_idx] = sort(longitude);
sst = ncread(ncfile, ‘sst’);
sst_sorted = sst(sort_idx, :, :); % Re-sort SST data according to longitude sorting
lat_idx = find(latitude >= lat_min & latitude <= lat_max);
lon_idx = find(longitude >= lon_min & longitude <= lon_max);
sst_region = sst_sorted(lon_idx, lat_idx, :);
sst_sum_weak = sst_sum_weak + mean(sst_region, 3); % Mean over time
end
for i = 1:num_strong_files
ncfile = StrongTEJYears{i};
latitude = ncread(ncfile, ‘latitude’);
longitude = ncread(ncfile, ‘longitude’);
longitude(longitude < 0) = longitude(longitude < 0) + 360;
[longitude, sort_idx] = sort(longitude);
sst = ncread(ncfile, ‘sst’);
sst_sorted = sst(sort_idx, :, :);
lat_idx = find(latitude >= lat_min & latitude <= lat_max);
lon_idx = find(longitude >= lon_min & longitude <= lon_max);
sst_region = sst_sorted(lon_idx, lat_idx, :);
sst_sum_strong = sst_sum_strong + mean(sst_region, 3); % Mean over time
end
sst_avg_weak = sst_sum_weak / num_weak_files;
sst_avg_strong = sst_sum_strong / num_strong_files;
sst_diff = sst_avg_strong – sst_avg_weak;
figure;
[lon_mesh, lat_mesh] = meshgrid(longitude(lon_idx), latitude(lat_idx));
contourf(lon_mesh, lat_mesh, sst_diff’, 20, ‘EdgeColor’, ‘none’);
colormap jet;
colorbar;
caxis([-2, 2]);
c.Label.String = ‘Temperature (K)’;
c.Label.FontSize = 18;
c.Label.FontWeight = ‘bold’;
coast = load(‘coastlines’);
coastlon = coast.coastlon;
coastlat = coast.coastlat;
coastlon(coastlon < 0) = coastlon(coastlon < 0) + 360;
hold on;
plot(coastlon, coastlat, ‘k’, ‘LineWidth’, 1.5);
xlim([lon_min, lon_max]);
ylim([lat_min, lat_max]);
title(‘Difference: Strong – Weak TEJ Average SST’, ‘FontSize’, 14); I am plottting a simple sst difference plot. My lon data is in the range -180 to 180. I have converted it to 0 to 360. After plotting I am geeting these black patches (attached).
clear
clc
% Define the file paths for WeakTEJYears
WeakTEJYears = {
‘F:SST_MA1979.nc’
‘F:SST_MA1983.nc’
‘F:SST_MA1987.nc’
‘F:SST_MA1997.nc’
‘F:SST_MA2002.nc’
‘F:SST_MA2015.nc’
‘F:SST_MA2023.nc’
};
% Define the file paths for StrongTEJYears
StrongTEJYears = {
‘F:SST_MA1985.nc’
‘F:SST_MA1988.nc’
‘F:SST_MA1999.nc’
‘F:SST_MA2009.nc’
‘F:SST_MA2013.nc’
};
% Initialize variables to store the sum of SST data
sst_sum_weak = 0;
sst_sum_strong = 0;
num_weak_files = length(WeakTEJYears);
num_strong_files = length(StrongTEJYears);
lat_min = -25;
lat_max = 70;
lon_min = 0;
lon_max = 360;
for i = 1:num_weak_files
ncfile = WeakTEJYears{i};
latitude = ncread(ncfile, ‘latitude’);
longitude = ncread(ncfile, ‘longitude’);
longitude(longitude < 0) = longitude(longitude < 0) + 360;
[longitude, sort_idx] = sort(longitude);
sst = ncread(ncfile, ‘sst’);
sst_sorted = sst(sort_idx, :, :); % Re-sort SST data according to longitude sorting
lat_idx = find(latitude >= lat_min & latitude <= lat_max);
lon_idx = find(longitude >= lon_min & longitude <= lon_max);
sst_region = sst_sorted(lon_idx, lat_idx, :);
sst_sum_weak = sst_sum_weak + mean(sst_region, 3); % Mean over time
end
for i = 1:num_strong_files
ncfile = StrongTEJYears{i};
latitude = ncread(ncfile, ‘latitude’);
longitude = ncread(ncfile, ‘longitude’);
longitude(longitude < 0) = longitude(longitude < 0) + 360;
[longitude, sort_idx] = sort(longitude);
sst = ncread(ncfile, ‘sst’);
sst_sorted = sst(sort_idx, :, :);
lat_idx = find(latitude >= lat_min & latitude <= lat_max);
lon_idx = find(longitude >= lon_min & longitude <= lon_max);
sst_region = sst_sorted(lon_idx, lat_idx, :);
sst_sum_strong = sst_sum_strong + mean(sst_region, 3); % Mean over time
end
sst_avg_weak = sst_sum_weak / num_weak_files;
sst_avg_strong = sst_sum_strong / num_strong_files;
sst_diff = sst_avg_strong – sst_avg_weak;
figure;
[lon_mesh, lat_mesh] = meshgrid(longitude(lon_idx), latitude(lat_idx));
contourf(lon_mesh, lat_mesh, sst_diff’, 20, ‘EdgeColor’, ‘none’);
colormap jet;
colorbar;
caxis([-2, 2]);
c.Label.String = ‘Temperature (K)’;
c.Label.FontSize = 18;
c.Label.FontWeight = ‘bold’;
coast = load(‘coastlines’);
coastlon = coast.coastlon;
coastlat = coast.coastlat;
coastlon(coastlon < 0) = coastlon(coastlon < 0) + 360;
hold on;
plot(coastlon, coastlat, ‘k’, ‘LineWidth’, 1.5);
xlim([lon_min, lon_max]);
ylim([lat_min, lat_max]);
title(‘Difference: Strong – Weak TEJ Average SST’, ‘FontSize’, 14); spatial map, image analysis, matrix manipulation MATLAB Answers — New Questions
How to rotate rectangular with a an angle?
Hey Everone,
I would like to rotate a rectangula with a specific angle.
Any help
Thank youHey Everone,
I would like to rotate a rectangula with a specific angle.
Any help
Thank you Hey Everone,
I would like to rotate a rectangula with a specific angle.
Any help
Thank you rectangular- rotate MATLAB Answers — New Questions
Average Curvature of a Closed 3D Surface
Hi, All —
I would like to compute the average curvature of a closed 3D surface for which I know the inside-outside function, F(x,y,z)=0. (FWIW, centered on the origin and symmetric about all three Cartesian axes.)
I have implemented a couple of different approaches for Gaussian and mean curvature using divergence, the Hessian, the first and second fundamental forms, and other approaches of which I have a similarly weak grasp. I am generally able to get things to work for degenrate cases (e.g., a sphere), but if I increase the complexity of my object, I am tending to get answers that imply I am flirting with the precipice of numerical instability (e.g., imaginary results where Re(x)/Im(x)~10^8).
I like the idea of this approach because it "feels clean": (1) use continuous function; (2) apply magic; (3) integrate in spherical coordinates; and (4) profit. However, I am beginning to think that I need to tune out the sires sweetly singing and go for a more practical (i.e., tractable) approach.
My other idea is to start by using the inside-outside function to generate [X,Y,Z] similar to what is used by surf(). I can then use surfature() from the FEX to get the curvatures at every point on my [X,Y,Z] mesh. Finally, I could convert everything to spherical coordinates and integrate the curvature arrays to get average values.
My concern here is that reregularly-spaced [X,Y,Z] does not translate to regularly-spaced [r,theta,phi], so the calculation is somehow pathologically biased. I am also unsure about how to do the actual integration after converting my array to spherical coordinates.
Apologies for such a long text-dense question. I thought about trying to illustrate this better with a couple of code snippets, but the algebra is really messy and not all that informative.
Thanks, in advance.Hi, All —
I would like to compute the average curvature of a closed 3D surface for which I know the inside-outside function, F(x,y,z)=0. (FWIW, centered on the origin and symmetric about all three Cartesian axes.)
I have implemented a couple of different approaches for Gaussian and mean curvature using divergence, the Hessian, the first and second fundamental forms, and other approaches of which I have a similarly weak grasp. I am generally able to get things to work for degenrate cases (e.g., a sphere), but if I increase the complexity of my object, I am tending to get answers that imply I am flirting with the precipice of numerical instability (e.g., imaginary results where Re(x)/Im(x)~10^8).
I like the idea of this approach because it "feels clean": (1) use continuous function; (2) apply magic; (3) integrate in spherical coordinates; and (4) profit. However, I am beginning to think that I need to tune out the sires sweetly singing and go for a more practical (i.e., tractable) approach.
My other idea is to start by using the inside-outside function to generate [X,Y,Z] similar to what is used by surf(). I can then use surfature() from the FEX to get the curvatures at every point on my [X,Y,Z] mesh. Finally, I could convert everything to spherical coordinates and integrate the curvature arrays to get average values.
My concern here is that reregularly-spaced [X,Y,Z] does not translate to regularly-spaced [r,theta,phi], so the calculation is somehow pathologically biased. I am also unsure about how to do the actual integration after converting my array to spherical coordinates.
Apologies for such a long text-dense question. I thought about trying to illustrate this better with a couple of code snippets, but the algebra is really messy and not all that informative.
Thanks, in advance. Hi, All —
I would like to compute the average curvature of a closed 3D surface for which I know the inside-outside function, F(x,y,z)=0. (FWIW, centered on the origin and symmetric about all three Cartesian axes.)
I have implemented a couple of different approaches for Gaussian and mean curvature using divergence, the Hessian, the first and second fundamental forms, and other approaches of which I have a similarly weak grasp. I am generally able to get things to work for degenrate cases (e.g., a sphere), but if I increase the complexity of my object, I am tending to get answers that imply I am flirting with the precipice of numerical instability (e.g., imaginary results where Re(x)/Im(x)~10^8).
I like the idea of this approach because it "feels clean": (1) use continuous function; (2) apply magic; (3) integrate in spherical coordinates; and (4) profit. However, I am beginning to think that I need to tune out the sires sweetly singing and go for a more practical (i.e., tractable) approach.
My other idea is to start by using the inside-outside function to generate [X,Y,Z] similar to what is used by surf(). I can then use surfature() from the FEX to get the curvatures at every point on my [X,Y,Z] mesh. Finally, I could convert everything to spherical coordinates and integrate the curvature arrays to get average values.
My concern here is that reregularly-spaced [X,Y,Z] does not translate to regularly-spaced [r,theta,phi], so the calculation is somehow pathologically biased. I am also unsure about how to do the actual integration after converting my array to spherical coordinates.
Apologies for such a long text-dense question. I thought about trying to illustrate this better with a couple of code snippets, but the algebra is really messy and not all that informative.
Thanks, in advance. differential geometry, curvature, spherical averaging MATLAB Answers — New Questions
how to convert MRMR feature selection from matlab to C++?
how to convert MRMR feature selection from matlab to C++?how to convert MRMR feature selection from matlab to C++? how to convert MRMR feature selection from matlab to C++? mrmr MATLAB Answers — New Questions
How to multiply two matrices with nested for loops ?
How can I do that with two matrices with any dimensions that can multiply ?
Thank youHow can I do that with two matrices with any dimensions that can multiply ?
Thank you How can I do that with two matrices with any dimensions that can multiply ?
Thank you matrix, array, multiple MATLAB Answers — New Questions
How to make a fill for standard deviation around a polar plot?
Hello,
I am trying to figure out how to make a standard deviation fill around the mean plotted in polarplot(). Here is my code:
deg = [330 300 270 240 210 180 150 120 90 60 30 0 330];
m_1 = [0.895 0.76 1.35 2.07 2.234 1.167 0.367 0.332 0.410 0.842 0.942 0.760 0.895];
s_1 = [1.505 1.127 1.60 2.53 2.18 1.82 0.437 0.41 0.49 0.88 1.20 1.53 1.505];
figure
pax = polaraxes;
polaraxes(pax)
polarplot(deg2rad(deg),m_1,’r-‘,’LineWidth’,2)
How can I add a translucent fill around my line to represent the standard deviation?
Thanks!Hello,
I am trying to figure out how to make a standard deviation fill around the mean plotted in polarplot(). Here is my code:
deg = [330 300 270 240 210 180 150 120 90 60 30 0 330];
m_1 = [0.895 0.76 1.35 2.07 2.234 1.167 0.367 0.332 0.410 0.842 0.942 0.760 0.895];
s_1 = [1.505 1.127 1.60 2.53 2.18 1.82 0.437 0.41 0.49 0.88 1.20 1.53 1.505];
figure
pax = polaraxes;
polaraxes(pax)
polarplot(deg2rad(deg),m_1,’r-‘,’LineWidth’,2)
How can I add a translucent fill around my line to represent the standard deviation?
Thanks! Hello,
I am trying to figure out how to make a standard deviation fill around the mean plotted in polarplot(). Here is my code:
deg = [330 300 270 240 210 180 150 120 90 60 30 0 330];
m_1 = [0.895 0.76 1.35 2.07 2.234 1.167 0.367 0.332 0.410 0.842 0.942 0.760 0.895];
s_1 = [1.505 1.127 1.60 2.53 2.18 1.82 0.437 0.41 0.49 0.88 1.20 1.53 1.505];
figure
pax = polaraxes;
polaraxes(pax)
polarplot(deg2rad(deg),m_1,’r-‘,’LineWidth’,2)
How can I add a translucent fill around my line to represent the standard deviation?
Thanks! figure, plot, plotting, polarplot, image, matlab MATLAB Answers — New Questions
Simscape model keeps on crashing
Hello everyone,
I have been trying to run my model which is a simscape electrical based EV model. It used to run, but now it is crashing after 15 sec, and sometimes it shows error such as "The exception unknown software exception (0x0000008) in the application at the location 0x00007FFD32C4837A". What could be the issue.
I had model this using 2024a, but I also tried to export it to 2023a because I thought there migh be some issue with 2024a. Still the issue prevails. What could be the issue fi anyone knows?Hello everyone,
I have been trying to run my model which is a simscape electrical based EV model. It used to run, but now it is crashing after 15 sec, and sometimes it shows error such as "The exception unknown software exception (0x0000008) in the application at the location 0x00007FFD32C4837A". What could be the issue.
I had model this using 2024a, but I also tried to export it to 2023a because I thought there migh be some issue with 2024a. Still the issue prevails. What could be the issue fi anyone knows? Hello everyone,
I have been trying to run my model which is a simscape electrical based EV model. It used to run, but now it is crashing after 15 sec, and sometimes it shows error such as "The exception unknown software exception (0x0000008) in the application at the location 0x00007FFD32C4837A". What could be the issue.
I had model this using 2024a, but I also tried to export it to 2023a because I thought there migh be some issue with 2024a. Still the issue prevails. What could be the issue fi anyone knows? simscape, power_electronics_control MATLAB Answers — New Questions
How can I export all the enumerated data types from m-file to an SLDD (Data Dictionary)? Can Enum be created in m-file? IF yes what’s the solution for this?
Creating Enum definition in the m-file and exporting back to SLDDCreating Enum definition in the m-file and exporting back to SLDD Creating Enum definition in the m-file and exporting back to SLDD sldd mfile export MATLAB Answers — New Questions
Simscape Multibody -: Model not assembled. The following violation occurred: Position Violation.
Hello,
I’m currently working on simulating a planar continuous parallel robot using Simscape, specifically the triskele bot. My goal is to modify the angles of either RevoluteJoint 0, 1 or 2 using an input. However, when I attempt this, I encounter the error mentioned below. Strangely, my model works without any errors when I provide torque input instead of motion. Could someone please help me identify where I’ve gone wrong? Thank you.
Project:
Is attached.
Error message:
Error:An error occurred while running the simulation and the simulation was terminated
Caused by:
[‘model_beam_1/Solver Configuration’]: Model not assembled. The following violation occurred: Position Violation. The failure occurred during the attempt to assemble all joints in the system and satisfy any motion inputs. If an Update Diagram operation completes successfully, the failure is likely caused by motion inputs. Consider adjusting the motion inputs to specify a different starting configuration. Also consider adjusting or adding joint targets to better guide the assembly.Hello,
I’m currently working on simulating a planar continuous parallel robot using Simscape, specifically the triskele bot. My goal is to modify the angles of either RevoluteJoint 0, 1 or 2 using an input. However, when I attempt this, I encounter the error mentioned below. Strangely, my model works without any errors when I provide torque input instead of motion. Could someone please help me identify where I’ve gone wrong? Thank you.
Project:
Is attached.
Error message:
Error:An error occurred while running the simulation and the simulation was terminated
Caused by:
[‘model_beam_1/Solver Configuration’]: Model not assembled. The following violation occurred: Position Violation. The failure occurred during the attempt to assemble all joints in the system and satisfy any motion inputs. If an Update Diagram operation completes successfully, the failure is likely caused by motion inputs. Consider adjusting the motion inputs to specify a different starting configuration. Also consider adjusting or adding joint targets to better guide the assembly. Hello,
I’m currently working on simulating a planar continuous parallel robot using Simscape, specifically the triskele bot. My goal is to modify the angles of either RevoluteJoint 0, 1 or 2 using an input. However, when I attempt this, I encounter the error mentioned below. Strangely, my model works without any errors when I provide torque input instead of motion. Could someone please help me identify where I’ve gone wrong? Thank you.
Project:
Is attached.
Error message:
Error:An error occurred while running the simulation and the simulation was terminated
Caused by:
[‘model_beam_1/Solver Configuration’]: Model not assembled. The following violation occurred: Position Violation. The failure occurred during the attempt to assemble all joints in the system and satisfy any motion inputs. If an Update Diagram operation completes successfully, the failure is likely caused by motion inputs. Consider adjusting the motion inputs to specify a different starting configuration. Also consider adjusting or adding joint targets to better guide the assembly. position violation, simscape, beam model, simulink MATLAB Answers — New Questions
How to extract patch of 4*4 size on the extracted SIFT features Keypoint (for eg: SIFT feature of an image 961*128)?
Extraction a patch size of 4*4 on the keypoints extracted from the SIFT feature extraction.
example for an image I have got SIFT feature as 650*128.Extraction a patch size of 4*4 on the keypoints extracted from the SIFT feature extraction.
example for an image I have got SIFT feature as 650*128. Extraction a patch size of 4*4 on the keypoints extracted from the SIFT feature extraction.
example for an image I have got SIFT feature as 650*128. patch extraction MATLAB Answers — New Questions