Tag Archives: matlab
Is it possible to “move” points in 3D?
I have this scatter3 graph, I’m generating from CIE Lab coordinates :
Would it be too far-fetch to be able to select any points on the graph and "move" them in some direction? And recover their new positions?I have this scatter3 graph, I’m generating from CIE Lab coordinates :
Would it be too far-fetch to be able to select any points on the graph and "move" them in some direction? And recover their new positions? I have this scatter3 graph, I’m generating from CIE Lab coordinates :
Would it be too far-fetch to be able to select any points on the graph and "move" them in some direction? And recover their new positions? scatter3, editing points in 3d, cie lab, move points in 3d, handles MATLAB Answers — New Questions
Why in the Hyperspectral Viewer app, the plotted spectrum using “add spectral plot” is not able to be saved by using the save option just above the spectral plot window?
In the Hyperspectral Viewer app, the plotted spectrum using "add spectral plot" is not able to be saved by using the save option just above the spectral plot window.In the Hyperspectral Viewer app, the plotted spectrum using "add spectral plot" is not able to be saved by using the save option just above the spectral plot window. In the Hyperspectral Viewer app, the plotted spectrum using "add spectral plot" is not able to be saved by using the save option just above the spectral plot window. hyperspectral image processing MATLAB Answers — New Questions
How can I run a parametric sweep of an ODE using sys & dsolve?
I’m trying to solve a basic ODE (transient energy balance in a stirred tank). I can easily solve my equation using this code below (simplified).
However, I need to automate a parametric sweep so I can vary things like the size of the tank or the heater duty etc and plot all the curves on a single graph. I’ve looked around this forum and the support docs but can’t really find a solution. I would like to stick to the symbolic toolbox if possible, since it’s much neater and elegant than definiting separate functions the old way, but if that’s the only solution, then happy to do that.
Is there a simple way to do this? I’ve attempted to use a for loop but I get index errors pop up.
I haven’t used matlab since undergrad (10 years ago), so am a bit rusty.
syms T(t)
ode = m_w * Cp_w * (diff(T,t) – T_ref) == (m_in * Cp_w * (T_in – T_ref)) – (m_out * Cp_w * (T(t) – T_ref)) + Q_heater – (R_tot * (T(t) – T_amb) * A_ins);
cond = T(0) == T_amb;
TSol(t) = dsolve(ode,cond);
fplot(TSol,[0 3600]);I’m trying to solve a basic ODE (transient energy balance in a stirred tank). I can easily solve my equation using this code below (simplified).
However, I need to automate a parametric sweep so I can vary things like the size of the tank or the heater duty etc and plot all the curves on a single graph. I’ve looked around this forum and the support docs but can’t really find a solution. I would like to stick to the symbolic toolbox if possible, since it’s much neater and elegant than definiting separate functions the old way, but if that’s the only solution, then happy to do that.
Is there a simple way to do this? I’ve attempted to use a for loop but I get index errors pop up.
I haven’t used matlab since undergrad (10 years ago), so am a bit rusty.
syms T(t)
ode = m_w * Cp_w * (diff(T,t) – T_ref) == (m_in * Cp_w * (T_in – T_ref)) – (m_out * Cp_w * (T(t) – T_ref)) + Q_heater – (R_tot * (T(t) – T_amb) * A_ins);
cond = T(0) == T_amb;
TSol(t) = dsolve(ode,cond);
fplot(TSol,[0 3600]); I’m trying to solve a basic ODE (transient energy balance in a stirred tank). I can easily solve my equation using this code below (simplified).
However, I need to automate a parametric sweep so I can vary things like the size of the tank or the heater duty etc and plot all the curves on a single graph. I’ve looked around this forum and the support docs but can’t really find a solution. I would like to stick to the symbolic toolbox if possible, since it’s much neater and elegant than definiting separate functions the old way, but if that’s the only solution, then happy to do that.
Is there a simple way to do this? I’ve attempted to use a for loop but I get index errors pop up.
I haven’t used matlab since undergrad (10 years ago), so am a bit rusty.
syms T(t)
ode = m_w * Cp_w * (diff(T,t) – T_ref) == (m_in * Cp_w * (T_in – T_ref)) – (m_out * Cp_w * (T(t) – T_ref)) + Q_heater – (R_tot * (T(t) – T_amb) * A_ins);
cond = T(0) == T_amb;
TSol(t) = dsolve(ode,cond);
fplot(TSol,[0 3600]); ode, differential equations, symbolic, parametric, dsolve MATLAB Answers — New Questions
how to control the grid size and scale?
I had a grid size of 200 * 200, but I wanted to increase the resolution, so I changed it to 400 * 400. Of course, 1 grid square means 1m.
However, when I increased the size to 400, I found out that there were some structural problems in subsequent calculations.
So I want to maintain the grid size at 200 * 200, but adjust the scale so that one square means 0.5m,
and there are no problems in subsequent calculations.
Below is the current code.
originalnewGridSize = 200;
newGridSize = 400;
[x, y] = meshgrid(linspace(1, originalnewGridSize, newGridSize), linspace(1, originalnewGridSize, newGridSize));I had a grid size of 200 * 200, but I wanted to increase the resolution, so I changed it to 400 * 400. Of course, 1 grid square means 1m.
However, when I increased the size to 400, I found out that there were some structural problems in subsequent calculations.
So I want to maintain the grid size at 200 * 200, but adjust the scale so that one square means 0.5m,
and there are no problems in subsequent calculations.
Below is the current code.
originalnewGridSize = 200;
newGridSize = 400;
[x, y] = meshgrid(linspace(1, originalnewGridSize, newGridSize), linspace(1, originalnewGridSize, newGridSize)); I had a grid size of 200 * 200, but I wanted to increase the resolution, so I changed it to 400 * 400. Of course, 1 grid square means 1m.
However, when I increased the size to 400, I found out that there were some structural problems in subsequent calculations.
So I want to maintain the grid size at 200 * 200, but adjust the scale so that one square means 0.5m,
and there are no problems in subsequent calculations.
Below is the current code.
originalnewGridSize = 200;
newGridSize = 400;
[x, y] = meshgrid(linspace(1, originalnewGridSize, newGridSize), linspace(1, originalnewGridSize, newGridSize)); grid, meshgrid, scale, control, gridsize MATLAB Answers — New Questions
How do I properly embed custom font in a web app developed in App Designer?
Hi all,
I have been building a web app through App Designer on MATLAB R2023b and tried to use the custom fonts "Kanit" and "Montgomery" for my UI.
Although the custom fonts show in the app on my developer desktop after copying them to "<matlabroot>sysjavajrewin64jrelibfonts", the app shows a fallback font on a different computer through my LAN.
My question is how do I ensure that the web app also use these custom fonts on computers that do not have them installed?
I have attempted to embed an HTML block in the app UI to access the Google Font API with the following code,
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=kanit"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=montgomery">
but my Chrome browser’s console returned the following error message "Refused to load the stylesheet ‘https://fonts.googleapis.com/css?family=kanit’ because it violates the following Content Security Policy directive: "style-src ‘self’ ‘unsafe-inline’". Note that ‘style-src-elem’ was not explicitly set, so ‘style-src’ is used as a fallback."
All help would be greatly appreciated – thank you!Hi all,
I have been building a web app through App Designer on MATLAB R2023b and tried to use the custom fonts "Kanit" and "Montgomery" for my UI.
Although the custom fonts show in the app on my developer desktop after copying them to "<matlabroot>sysjavajrewin64jrelibfonts", the app shows a fallback font on a different computer through my LAN.
My question is how do I ensure that the web app also use these custom fonts on computers that do not have them installed?
I have attempted to embed an HTML block in the app UI to access the Google Font API with the following code,
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=kanit"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=montgomery">
but my Chrome browser’s console returned the following error message "Refused to load the stylesheet ‘https://fonts.googleapis.com/css?family=kanit’ because it violates the following Content Security Policy directive: "style-src ‘self’ ‘unsafe-inline’". Note that ‘style-src-elem’ was not explicitly set, so ‘style-src’ is used as a fallback."
All help would be greatly appreciated – thank you! Hi all,
I have been building a web app through App Designer on MATLAB R2023b and tried to use the custom fonts "Kanit" and "Montgomery" for my UI.
Although the custom fonts show in the app on my developer desktop after copying them to "<matlabroot>sysjavajrewin64jrelibfonts", the app shows a fallback font on a different computer through my LAN.
My question is how do I ensure that the web app also use these custom fonts on computers that do not have them installed?
I have attempted to embed an HTML block in the app UI to access the Google Font API with the following code,
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=kanit"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=montgomery">
but my Chrome browser’s console returned the following error message "Refused to load the stylesheet ‘https://fonts.googleapis.com/css?family=kanit’ because it violates the following Content Security Policy directive: "style-src ‘self’ ‘unsafe-inline’". Note that ‘style-src-elem’ was not explicitly set, so ‘style-src’ is used as a fallback."
All help would be greatly appreciated – thank you! web app, appdesigner, app designer, font MATLAB Answers — New Questions
Question about Tire-Road Interaction (Magic Formula)
Refer to help document of matlab, it said that when velocity is lowwer than a specific value, the block saturates the slip denominator as Vlow.So,When velocity is close to 0, sliping will be occured even if there is no driving torque input in this mathod.since Fx is calculated by Fz and Slipping, Fx will be more than 0. what i want to ask is how to solve this, avoiding Fx>0 at no torque and no velocity point.Refer to help document of matlab, it said that when velocity is lowwer than a specific value, the block saturates the slip denominator as Vlow.So,When velocity is close to 0, sliping will be occured even if there is no driving torque input in this mathod.since Fx is calculated by Fz and Slipping, Fx will be more than 0. what i want to ask is how to solve this, avoiding Fx>0 at no torque and no velocity point. Refer to help document of matlab, it said that when velocity is lowwer than a specific value, the block saturates the slip denominator as Vlow.So,When velocity is close to 0, sliping will be occured even if there is no driving torque input in this mathod.since Fx is calculated by Fz and Slipping, Fx will be more than 0. what i want to ask is how to solve this, avoiding Fx>0 at no torque and no velocity point. tire, magic formula MATLAB Answers — New Questions
“webread” does not work for Yahoo Option Chains page
Going to any Yahoo Option Chain page, copy and paste the URL to webread returns an error. For example:
webread(‘https://finance.yahoo.com/quote/AAPL/options/’)
returns
The server returned the status 404 with message "Not Found"
It works for stock prices, but not for option chains. Is this a Yahoo protection issue or a limitation of webread?Going to any Yahoo Option Chain page, copy and paste the URL to webread returns an error. For example:
webread(‘https://finance.yahoo.com/quote/AAPL/options/’)
returns
The server returned the status 404 with message "Not Found"
It works for stock prices, but not for option chains. Is this a Yahoo protection issue or a limitation of webread? Going to any Yahoo Option Chain page, copy and paste the URL to webread returns an error. For example:
webread(‘https://finance.yahoo.com/quote/AAPL/options/’)
returns
The server returned the status 404 with message "Not Found"
It works for stock prices, but not for option chains. Is this a Yahoo protection issue or a limitation of webread? webread MATLAB Answers — New Questions
Find overlap percentage of two plots
I am trying to find the percentage of points that overlap in two stem plots. I saw an answer on here using the mean to compare this, but I want to know overlap not average. How would I go about doing this for a simple plot.
ex:
input_signal = sin(2*pi*100*t) + sin(2*pi*300*t);
output_signal = FiltBank(input_signal);
Thank you for your time!I am trying to find the percentage of points that overlap in two stem plots. I saw an answer on here using the mean to compare this, but I want to know overlap not average. How would I go about doing this for a simple plot.
ex:
input_signal = sin(2*pi*100*t) + sin(2*pi*300*t);
output_signal = FiltBank(input_signal);
Thank you for your time! I am trying to find the percentage of points that overlap in two stem plots. I saw an answer on here using the mean to compare this, but I want to know overlap not average. How would I go about doing this for a simple plot.
ex:
input_signal = sin(2*pi*100*t) + sin(2*pi*300*t);
output_signal = FiltBank(input_signal);
Thank you for your time! plot, compare MATLAB Answers — New Questions
Find Index of Selected Drop Down in another variable (App Designer)
Hello Matlab App Developer wizards.
Had a quick question. So I have this drop-down in a matlab app that calls a variable "Yield_raw(:,2)" to create a list. I want to know the index (i.e. row and column) of "Yield_raw" when this is selected. Any pointers? My code looks as follows:
Creates drop down
function ImportYieldFileButtonPushed(app, event)
[Yield_import, Yield_location] = uigetfile(‘*.xlsx’, ‘Select Yield File’, ‘\chlm2efs01US_Share’);
Yield_raw = readtable([Yield_location, Yield_import]);
Yield_raw = table2cell(Yield_raw(:,[1,3:13]));
if exist(‘Yield_raw’,’var’)
app.Lamp_Yield.Color =’g’;
end
app.ProcessDropDown.Items = Yield_raw(:,2);
Selected drop down
function ProcessDropDownClicked(app, event)
% item = event.InteractionInformation.Item;
%%HOW DO I GET THE INDEX IN YIELD_RAW FOR THE VALUE I SELECTED IN THE DROP DOWN []
endHello Matlab App Developer wizards.
Had a quick question. So I have this drop-down in a matlab app that calls a variable "Yield_raw(:,2)" to create a list. I want to know the index (i.e. row and column) of "Yield_raw" when this is selected. Any pointers? My code looks as follows:
Creates drop down
function ImportYieldFileButtonPushed(app, event)
[Yield_import, Yield_location] = uigetfile(‘*.xlsx’, ‘Select Yield File’, ‘\chlm2efs01US_Share’);
Yield_raw = readtable([Yield_location, Yield_import]);
Yield_raw = table2cell(Yield_raw(:,[1,3:13]));
if exist(‘Yield_raw’,’var’)
app.Lamp_Yield.Color =’g’;
end
app.ProcessDropDown.Items = Yield_raw(:,2);
Selected drop down
function ProcessDropDownClicked(app, event)
% item = event.InteractionInformation.Item;
%%HOW DO I GET THE INDEX IN YIELD_RAW FOR THE VALUE I SELECTED IN THE DROP DOWN []
end Hello Matlab App Developer wizards.
Had a quick question. So I have this drop-down in a matlab app that calls a variable "Yield_raw(:,2)" to create a list. I want to know the index (i.e. row and column) of "Yield_raw" when this is selected. Any pointers? My code looks as follows:
Creates drop down
function ImportYieldFileButtonPushed(app, event)
[Yield_import, Yield_location] = uigetfile(‘*.xlsx’, ‘Select Yield File’, ‘\chlm2efs01US_Share’);
Yield_raw = readtable([Yield_location, Yield_import]);
Yield_raw = table2cell(Yield_raw(:,[1,3:13]));
if exist(‘Yield_raw’,’var’)
app.Lamp_Yield.Color =’g’;
end
app.ProcessDropDown.Items = Yield_raw(:,2);
Selected drop down
function ProcessDropDownClicked(app, event)
% item = event.InteractionInformation.Item;
%%HOW DO I GET THE INDEX IN YIELD_RAW FOR THE VALUE I SELECTED IN THE DROP DOWN []
end appdesigner, app designer, graph, matlab, matrix, input, index, indexing, find, sort, import, integration, matrices, matlab gui, matlab code, mathematics, matrix array, matlab coder, matlab function, matlab compiler, matrix manipulation, embedded matlab function, function, functions MATLAB Answers — New Questions
Im unable to start this question and dont know how to approach it
Post Content Post Content functions, matlab function MATLAB Answers — New Questions
I didn’t understand it how they completed it?
Post Content Post Content matlab, functions, s-function MATLAB Answers — New Questions
Running reference application “HEV Multimode Reference Application” gives errors on R2023b
What fixup can anyone recommend for this set of errors running the application "HEV Multimode Reference Application" on R2023b MATLAB Cloud?
Warning: An error occurred while evaluating "loc_createToolchain" in "/MATLAB/toolbox/coder/autosar/rtwTargetInfo.p": Unrecognized function or variable ‘autosarroot’.
This custom registration is not loaded.
Updating Model Reference Simulation Targets
### Searching for referenced models in model ‘HevMmReferenceApplication’.
### Found 7 model references to update.
### Starting serial model reference simulation build.
### Build procedure for BattHevMm aborted due to an error.
Build Summary
Simulation targets built:
Model Action Rebuild Reason
=========================================================
BattHevMm Failed BattHevMm_msf.mexa64 does not exist.
0 of 7 models built (0 models already up to date)
Build duration: 0h 0m 26.426s
Unable to update models referenced by ‘HevMmReferenceApplication’.
Caused by:
Undefined function ‘slcifeature’ for input arguments of type ‘char’.
Component:Simulink | Category:Block diagram errorWhat fixup can anyone recommend for this set of errors running the application "HEV Multimode Reference Application" on R2023b MATLAB Cloud?
Warning: An error occurred while evaluating "loc_createToolchain" in "/MATLAB/toolbox/coder/autosar/rtwTargetInfo.p": Unrecognized function or variable ‘autosarroot’.
This custom registration is not loaded.
Updating Model Reference Simulation Targets
### Searching for referenced models in model ‘HevMmReferenceApplication’.
### Found 7 model references to update.
### Starting serial model reference simulation build.
### Build procedure for BattHevMm aborted due to an error.
Build Summary
Simulation targets built:
Model Action Rebuild Reason
=========================================================
BattHevMm Failed BattHevMm_msf.mexa64 does not exist.
0 of 7 models built (0 models already up to date)
Build duration: 0h 0m 26.426s
Unable to update models referenced by ‘HevMmReferenceApplication’.
Caused by:
Undefined function ‘slcifeature’ for input arguments of type ‘char’.
Component:Simulink | Category:Block diagram error What fixup can anyone recommend for this set of errors running the application "HEV Multimode Reference Application" on R2023b MATLAB Cloud?
Warning: An error occurred while evaluating "loc_createToolchain" in "/MATLAB/toolbox/coder/autosar/rtwTargetInfo.p": Unrecognized function or variable ‘autosarroot’.
This custom registration is not loaded.
Updating Model Reference Simulation Targets
### Searching for referenced models in model ‘HevMmReferenceApplication’.
### Found 7 model references to update.
### Starting serial model reference simulation build.
### Build procedure for BattHevMm aborted due to an error.
Build Summary
Simulation targets built:
Model Action Rebuild Reason
=========================================================
BattHevMm Failed BattHevMm_msf.mexa64 does not exist.
0 of 7 models built (0 models already up to date)
Build duration: 0h 0m 26.426s
Unable to update models referenced by ‘HevMmReferenceApplication’.
Caused by:
Undefined function ‘slcifeature’ for input arguments of type ‘char’.
Component:Simulink | Category:Block diagram error error, autosarroot MATLAB Answers — New Questions
Inertial parameters mismatch between URDF and official manual of UR5e
Hello,
I am using UR5e robot for a project where I need to develop a system model and simulate it. While I was studying the inertial parameters I found mismatch in the values of mass, centre of mass, and Inertia of joints between the URDF files and official guide. Can you please tell me which one is correct?
Official manual from website (https://www.universal-robots.com/articles/ur/application-installation/dh-parameters-for-calculations-of-kinematics-and-dynamics/)
From URDF fileHello,
I am using UR5e robot for a project where I need to develop a system model and simulate it. While I was studying the inertial parameters I found mismatch in the values of mass, centre of mass, and Inertia of joints between the URDF files and official guide. Can you please tell me which one is correct?
Official manual from website (https://www.universal-robots.com/articles/ur/application-installation/dh-parameters-for-calculations-of-kinematics-and-dynamics/)
From URDF file Hello,
I am using UR5e robot for a project where I need to develop a system model and simulate it. While I was studying the inertial parameters I found mismatch in the values of mass, centre of mass, and Inertia of joints between the URDF files and official guide. Can you please tell me which one is correct?
Official manual from website (https://www.universal-robots.com/articles/ur/application-installation/dh-parameters-for-calculations-of-kinematics-and-dynamics/)
From URDF file inertial parameters, robotics, ur5e, urdf, robotic toolbox MATLAB Answers — New Questions
Separate and plot individual filter responses
I am trying to create a plot similar to the attached image! I want to see the individual response each filter gives while displaying the center frequency of that filter on the y, adding together all of the responses at the top. I want to do this to display how much each filter is contributing and where it is most active. I was trying to use plot with CenterFreqs as my y but keep getting errors. This is what I have:
% Parameters
fs = 16e3;
t = 0:(1/fs):0.03;
t = t(:); % ensure column vector
numFilts = 32;
signal_freq = 100; % frequency of input signal
range = [50 8000];
gammaFiltBank = gammatoneFilterBank(range, numFilts, fs); % set fs explicitly
% Generate input signal
A=1;
input_signal = A*sin(2*pi*signal_freq*t);
% Get the center frequencies of the filters
CenterFreqs = getCenterFrequencies(gammaFiltBank);
% Process the input signal through the selected filters
output_signal = gammaFiltBank(input_signal);
Thank you for your time!I am trying to create a plot similar to the attached image! I want to see the individual response each filter gives while displaying the center frequency of that filter on the y, adding together all of the responses at the top. I want to do this to display how much each filter is contributing and where it is most active. I was trying to use plot with CenterFreqs as my y but keep getting errors. This is what I have:
% Parameters
fs = 16e3;
t = 0:(1/fs):0.03;
t = t(:); % ensure column vector
numFilts = 32;
signal_freq = 100; % frequency of input signal
range = [50 8000];
gammaFiltBank = gammatoneFilterBank(range, numFilts, fs); % set fs explicitly
% Generate input signal
A=1;
input_signal = A*sin(2*pi*signal_freq*t);
% Get the center frequencies of the filters
CenterFreqs = getCenterFrequencies(gammaFiltBank);
% Process the input signal through the selected filters
output_signal = gammaFiltBank(input_signal);
Thank you for your time! I am trying to create a plot similar to the attached image! I want to see the individual response each filter gives while displaying the center frequency of that filter on the y, adding together all of the responses at the top. I want to do this to display how much each filter is contributing and where it is most active. I was trying to use plot with CenterFreqs as my y but keep getting errors. This is what I have:
% Parameters
fs = 16e3;
t = 0:(1/fs):0.03;
t = t(:); % ensure column vector
numFilts = 32;
signal_freq = 100; % frequency of input signal
range = [50 8000];
gammaFiltBank = gammatoneFilterBank(range, numFilts, fs); % set fs explicitly
% Generate input signal
A=1;
input_signal = A*sin(2*pi*signal_freq*t);
% Get the center frequencies of the filters
CenterFreqs = getCenterFrequencies(gammaFiltBank);
% Process the input signal through the selected filters
output_signal = gammaFiltBank(input_signal);
Thank you for your time! center, frequency, plot MATLAB Answers — New Questions
What is the Image Processing Toolbox Convention for Input to freqz2() ?
I was trying to learn how to use the function freqz2 in the Image Processing Toolbox. That doc page says that the FIR filter input, h, is "in the form of a computational molecule." What is a "computational molecule?" A quick internet search didn’t help much. Is that a term commonly used in image processing?
Anyway, because I don’t know what that means, I searched around some more and found on What Is Image Filtering in the Spatial Domain? the statement that "The Image Processing Toolbox™ filter design functions return correlation kernels." So I assumed that h should be a correlation kernel (don’t know why the doc page for freqz2 doesn’t just say that if that is, in fact, the case).
Aside: the linked doc page on "What is Image Filtering …." has a mistake. The graphic immediately under the line "Computing the (2, 4) Output of Convolution" says "value of rotated convolution kernel" but it should say "value of rotated correlation kernel."
Define an input FIR filter
rng(100);
h = rand(5);
If that’s a correlation kernel with the origin at the center and the upper left corner corresponding to (-2,-2), then it seems to me that its 5×5 frequency response would be
H0 = fftshift(fft2(ifftshift(h)));
In order to get the same result from freqz2(), the input has to be rotated 180 deg
H1 = freqz2(rot90(h,-2),5,5,[1 1]);
isequal(H1,H0)
Inside the code of freqz2 is the comment "% Unrotate filter since FIR filters are rotated." Rotated relative to what?
Can anyone explain why that rot90 is needed on input to freqz2 or where the anlaysis has an incorrect assumption or calculation, or any other misunderstanding on my part?I was trying to learn how to use the function freqz2 in the Image Processing Toolbox. That doc page says that the FIR filter input, h, is "in the form of a computational molecule." What is a "computational molecule?" A quick internet search didn’t help much. Is that a term commonly used in image processing?
Anyway, because I don’t know what that means, I searched around some more and found on What Is Image Filtering in the Spatial Domain? the statement that "The Image Processing Toolbox™ filter design functions return correlation kernels." So I assumed that h should be a correlation kernel (don’t know why the doc page for freqz2 doesn’t just say that if that is, in fact, the case).
Aside: the linked doc page on "What is Image Filtering …." has a mistake. The graphic immediately under the line "Computing the (2, 4) Output of Convolution" says "value of rotated convolution kernel" but it should say "value of rotated correlation kernel."
Define an input FIR filter
rng(100);
h = rand(5);
If that’s a correlation kernel with the origin at the center and the upper left corner corresponding to (-2,-2), then it seems to me that its 5×5 frequency response would be
H0 = fftshift(fft2(ifftshift(h)));
In order to get the same result from freqz2(), the input has to be rotated 180 deg
H1 = freqz2(rot90(h,-2),5,5,[1 1]);
isequal(H1,H0)
Inside the code of freqz2 is the comment "% Unrotate filter since FIR filters are rotated." Rotated relative to what?
Can anyone explain why that rot90 is needed on input to freqz2 or where the anlaysis has an incorrect assumption or calculation, or any other misunderstanding on my part? I was trying to learn how to use the function freqz2 in the Image Processing Toolbox. That doc page says that the FIR filter input, h, is "in the form of a computational molecule." What is a "computational molecule?" A quick internet search didn’t help much. Is that a term commonly used in image processing?
Anyway, because I don’t know what that means, I searched around some more and found on What Is Image Filtering in the Spatial Domain? the statement that "The Image Processing Toolbox™ filter design functions return correlation kernels." So I assumed that h should be a correlation kernel (don’t know why the doc page for freqz2 doesn’t just say that if that is, in fact, the case).
Aside: the linked doc page on "What is Image Filtering …." has a mistake. The graphic immediately under the line "Computing the (2, 4) Output of Convolution" says "value of rotated convolution kernel" but it should say "value of rotated correlation kernel."
Define an input FIR filter
rng(100);
h = rand(5);
If that’s a correlation kernel with the origin at the center and the upper left corner corresponding to (-2,-2), then it seems to me that its 5×5 frequency response would be
H0 = fftshift(fft2(ifftshift(h)));
In order to get the same result from freqz2(), the input has to be rotated 180 deg
H1 = freqz2(rot90(h,-2),5,5,[1 1]);
isequal(H1,H0)
Inside the code of freqz2 is the comment "% Unrotate filter since FIR filters are rotated." Rotated relative to what?
Can anyone explain why that rot90 is needed on input to freqz2 or where the anlaysis has an incorrect assumption or calculation, or any other misunderstanding on my part? freqz2, fir filter convention MATLAB Answers — New Questions
Two-sample Anderson-Darling tests
Is there a function in Matlab which can perform a 2-sample Anderson-Darling test, as described/shown on Cross Validated or on R?
Indeed, to me, it looks like that the Matlab function called adtest is not distribution-free (i.e. it is not non-parametric), and it is limited to some known distributions (i.e. ‘norm’, ‘exp’, ‘ev’, ‘logn’ and ‘weibull’). In my case I have just two empirical distributions (coming from two datasets).Is there a function in Matlab which can perform a 2-sample Anderson-Darling test, as described/shown on Cross Validated or on R?
Indeed, to me, it looks like that the Matlab function called adtest is not distribution-free (i.e. it is not non-parametric), and it is limited to some known distributions (i.e. ‘norm’, ‘exp’, ‘ev’, ‘logn’ and ‘weibull’). In my case I have just two empirical distributions (coming from two datasets). Is there a function in Matlab which can perform a 2-sample Anderson-Darling test, as described/shown on Cross Validated or on R?
Indeed, to me, it looks like that the Matlab function called adtest is not distribution-free (i.e. it is not non-parametric), and it is limited to some known distributions (i.e. ‘norm’, ‘exp’, ‘ev’, ‘logn’ and ‘weibull’). In my case I have just two empirical distributions (coming from two datasets). adtest, anderson-darling test, statistical hypothesis test, two-sample MATLAB Answers — New Questions
How to normalize the rewards in RL
I recently learned normalizing the rewards is a key step in RL since rewards can vary over a large range of magnitudes, and the function approximators being used in RL are usually not invariant to the scale of the input. And It usually results in faster learning. I also learned that to normalize all discounted rewards across all episodes, we compute the mean and standard deviation of all the discounted rewards, and we subtract the mean from each discounted reward, and divide by the standard deviation.
How can I implement this in MATLAB? is it internally implemented in matlab? if not how can I transfer the necessary variables between episodes?I recently learned normalizing the rewards is a key step in RL since rewards can vary over a large range of magnitudes, and the function approximators being used in RL are usually not invariant to the scale of the input. And It usually results in faster learning. I also learned that to normalize all discounted rewards across all episodes, we compute the mean and standard deviation of all the discounted rewards, and we subtract the mean from each discounted reward, and divide by the standard deviation.
How can I implement this in MATLAB? is it internally implemented in matlab? if not how can I transfer the necessary variables between episodes? I recently learned normalizing the rewards is a key step in RL since rewards can vary over a large range of magnitudes, and the function approximators being used in RL are usually not invariant to the scale of the input. And It usually results in faster learning. I also learned that to normalize all discounted rewards across all episodes, we compute the mean and standard deviation of all the discounted rewards, and we subtract the mean from each discounted reward, and divide by the standard deviation.
How can I implement this in MATLAB? is it internally implemented in matlab? if not how can I transfer the necessary variables between episodes? reinforcement learning, rl, reward MATLAB Answers — New Questions
How to update value when different value is 0 in simulink?
Hi everyone,
I am creating a Simulink model to control an asynchronous motor with a current source inverter. I want to simulate a ramp-up by changing the frequency from an initial value to the rated value using a rate limiter. The issue is that I want to update the reference frequency value only when the counter (for selecting switches) reaches 0.
I have tried using the Signal Sample and Hold block as well as a combination of switches and memory blocks, but it is not working. The counter should always change from 0 to 180, but it is not behaving as expected.
Can anyone help with this?Hi everyone,
I am creating a Simulink model to control an asynchronous motor with a current source inverter. I want to simulate a ramp-up by changing the frequency from an initial value to the rated value using a rate limiter. The issue is that I want to update the reference frequency value only when the counter (for selecting switches) reaches 0.
I have tried using the Signal Sample and Hold block as well as a combination of switches and memory blocks, but it is not working. The counter should always change from 0 to 180, but it is not behaving as expected.
Can anyone help with this? Hi everyone,
I am creating a Simulink model to control an asynchronous motor with a current source inverter. I want to simulate a ramp-up by changing the frequency from an initial value to the rated value using a rate limiter. The issue is that I want to update the reference frequency value only when the counter (for selecting switches) reaches 0.
I have tried using the Signal Sample and Hold block as well as a combination of switches and memory blocks, but it is not working. The counter should always change from 0 to 180, but it is not behaving as expected.
Can anyone help with this? simulink, counter, electric_motor_control MATLAB Answers — New Questions
Plotting field over a discontinuous waveguide????
hi
I have x( 21 by 1) y(9by1) vectors
and i have to plot field over thesee points but the field is not defined over all points as there are discontinuities in waveguide..
I have a vector H of 150 by1 to be plotted in certain regions of x,y grid.
HOw to do that?
Thanks Gurpreethi
I have x( 21 by 1) y(9by1) vectors
and i have to plot field over thesee points but the field is not defined over all points as there are discontinuities in waveguide..
I have a vector H of 150 by1 to be plotted in certain regions of x,y grid.
HOw to do that?
Thanks Gurpreet hi
I have x( 21 by 1) y(9by1) vectors
and i have to plot field over thesee points but the field is not defined over all points as there are discontinuities in waveguide..
I have a vector H of 150 by1 to be plotted in certain regions of x,y grid.
HOw to do that?
Thanks Gurpreet waveguide MATLAB Answers — New Questions
Unable to Unpack Variables from Python to MATLAB Function in Simulink Model
Hi everyone,
I’m beginner in Matlab and I’m working on a project where I need to replace a scalar control block for an induction motor in Simulink with my own control block written in Python. The Python function calculates three variables that I need to pass back to MATLAB Function block, and convert to vector.
However, I’m running into an issue where MATLAB seems to treat these variables as non-iterable and can’t unpack them properly. Even though my Python function returns a tuple with the three variables, MATLAB can’t seem to process them as intended.
Here’s a summary of the setup:
MATLAB Function:
function Vabc = Run_in_Python(fRef)
Vabc = zeros(3, 1);
coder.extrinsic(‘py.ControllerPython.calc’);
result = cell(py.ControllerPython.calc(fRef));
Vabc = vertcat(result);
end
Error:
Python Error: TypeError: cannot unpack non-iterable int object Error in calc Error in ‘InductionMachineScalar/Control/Scalar controller/MATLAB Function’ (line 6)
Thanks in advance!Hi everyone,
I’m beginner in Matlab and I’m working on a project where I need to replace a scalar control block for an induction motor in Simulink with my own control block written in Python. The Python function calculates three variables that I need to pass back to MATLAB Function block, and convert to vector.
However, I’m running into an issue where MATLAB seems to treat these variables as non-iterable and can’t unpack them properly. Even though my Python function returns a tuple with the three variables, MATLAB can’t seem to process them as intended.
Here’s a summary of the setup:
MATLAB Function:
function Vabc = Run_in_Python(fRef)
Vabc = zeros(3, 1);
coder.extrinsic(‘py.ControllerPython.calc’);
result = cell(py.ControllerPython.calc(fRef));
Vabc = vertcat(result);
end
Error:
Python Error: TypeError: cannot unpack non-iterable int object Error in calc Error in ‘InductionMachineScalar/Control/Scalar controller/MATLAB Function’ (line 6)
Thanks in advance! Hi everyone,
I’m beginner in Matlab and I’m working on a project where I need to replace a scalar control block for an induction motor in Simulink with my own control block written in Python. The Python function calculates three variables that I need to pass back to MATLAB Function block, and convert to vector.
However, I’m running into an issue where MATLAB seems to treat these variables as non-iterable and can’t unpack them properly. Even though my Python function returns a tuple with the three variables, MATLAB can’t seem to process them as intended.
Here’s a summary of the setup:
MATLAB Function:
function Vabc = Run_in_Python(fRef)
Vabc = zeros(3, 1);
coder.extrinsic(‘py.ControllerPython.calc’);
result = cell(py.ControllerPython.calc(fRef));
Vabc = vertcat(result);
end
Error:
Python Error: TypeError: cannot unpack non-iterable int object Error in calc Error in ‘InductionMachineScalar/Control/Scalar controller/MATLAB Function’ (line 6)
Thanks in advance! matlab simulink python integration coder.extrinsic, simulink, python, cell arrays MATLAB Answers — New Questions