Category: Matlab
Category Archives: Matlab
Can function [s,h] = silhouette(X, clust, distance, varargin) be run using parfor (parallel computation)?
function [s,h] = silhouette(X, clust, distance, varargin)
X is in the order of 10^5, and it’s taking too long time to compute for all data points. How can I accelerate using parallel computation?function [s,h] = silhouette(X, clust, distance, varargin)
X is in the order of 10^5, and it’s taking too long time to compute for all data points. How can I accelerate using parallel computation? function [s,h] = silhouette(X, clust, distance, varargin)
X is in the order of 10^5, and it’s taking too long time to compute for all data points. How can I accelerate using parallel computation? silhoutte, parfor MATLAB Answers — New Questions
Testing private functions in classes
I’m wondering what the best way is to write unit tests for private functions and properties in classes. Say for example, I have a class that represents a ball launched as a projectile:
class ball
%
properties (Access = private)
initialSpeed = 25; %m/s
acceleration = -10; %m/s^2
end
%
methods
function distTravelled = getDistanceTravelled(obj, timeElapsed)
% Estimate total distance traveled by the ball
% (I know this is a bad approximation)
currSpeed = obj.getCurrSpeed(timeElapsed);
distTravelled = 0.5 * (obj.initialSpeed + currSpeed) * timeElapsed;
end
end
%
methods (Access = private)
function currSpeed = getCurrSpeed(obj, timeElapsed)
%Calculate current speed of ball
currSpeed = obj.initialSpeed + obj.acceleration * timeElapsed;
end
end
end
How should I write a test to check that the values for acceleration or that the value returned by the method getCurrSpeed is accurate? Should I just allow access to the testing functions?I’m wondering what the best way is to write unit tests for private functions and properties in classes. Say for example, I have a class that represents a ball launched as a projectile:
class ball
%
properties (Access = private)
initialSpeed = 25; %m/s
acceleration = -10; %m/s^2
end
%
methods
function distTravelled = getDistanceTravelled(obj, timeElapsed)
% Estimate total distance traveled by the ball
% (I know this is a bad approximation)
currSpeed = obj.getCurrSpeed(timeElapsed);
distTravelled = 0.5 * (obj.initialSpeed + currSpeed) * timeElapsed;
end
end
%
methods (Access = private)
function currSpeed = getCurrSpeed(obj, timeElapsed)
%Calculate current speed of ball
currSpeed = obj.initialSpeed + obj.acceleration * timeElapsed;
end
end
end
How should I write a test to check that the values for acceleration or that the value returned by the method getCurrSpeed is accurate? Should I just allow access to the testing functions? I’m wondering what the best way is to write unit tests for private functions and properties in classes. Say for example, I have a class that represents a ball launched as a projectile:
class ball
%
properties (Access = private)
initialSpeed = 25; %m/s
acceleration = -10; %m/s^2
end
%
methods
function distTravelled = getDistanceTravelled(obj, timeElapsed)
% Estimate total distance traveled by the ball
% (I know this is a bad approximation)
currSpeed = obj.getCurrSpeed(timeElapsed);
distTravelled = 0.5 * (obj.initialSpeed + currSpeed) * timeElapsed;
end
end
%
methods (Access = private)
function currSpeed = getCurrSpeed(obj, timeElapsed)
%Calculate current speed of ball
currSpeed = obj.initialSpeed + obj.acceleration * timeElapsed;
end
end
end
How should I write a test to check that the values for acceleration or that the value returned by the method getCurrSpeed is accurate? Should I just allow access to the testing functions? unit tests, object-oriented progamming, oop MATLAB Answers — New Questions
How can I connect CANopen with MATLAB?
Hello everyone,
I am trying to build a GUI with MATLAB for a machine which uses CANopen as a fieldbus system. I would like to know how could I connect CANopen with MATLAB?
Would be great if someone can help meHello everyone,
I am trying to build a GUI with MATLAB for a machine which uses CANopen as a fieldbus system. I would like to know how could I connect CANopen with MATLAB?
Would be great if someone can help me Hello everyone,
I am trying to build a GUI with MATLAB for a machine which uses CANopen as a fieldbus system. I would like to know how could I connect CANopen with MATLAB?
Would be great if someone can help me canopen, matlab gui, connect, matlab, fieldbus MATLAB Answers — New Questions
Using STM32CubeMX and Creating Global Init Functions
I have been intermittently attempting to use a Arduino Giga R1 with Simulink. I have, to my knowledge setup a simple example within a STM32 ioc file (derived from this setup: https://github.com/szabo-tamas/GigaR1Init). However in the building process within Simulink, it fails due to init functions needing to be set to global functions. I have followed all steps within the stm32cubemx guide on mathworks. Current information about how to set up in stm32cubemx: https://www.mathworks.com/help/supportpkg/stmicroelectronicsstm32f4discovery/ug/Getting-started-stm32cubemx.html.
Are there any guides on how to accomplish this appropriately or correctly within matlab/simulink environment, instead of what was recommended within the STM32 community here: https://community.st.com/t5/stm32cubemx-mcus/how-to-change-init-functions-to-global/td-p/53187. I drafted a simple function to update the init function-calls to be externs, not saying it couldnt be optimized, or improved (see attached). I believe this should enable building the simple example, however I still receive the same error when attempting to build code.
Current error when I attempt to build:
Every init function must be configured to generate a global function call instead of static functions call in STM32CubeMX project.I have been intermittently attempting to use a Arduino Giga R1 with Simulink. I have, to my knowledge setup a simple example within a STM32 ioc file (derived from this setup: https://github.com/szabo-tamas/GigaR1Init). However in the building process within Simulink, it fails due to init functions needing to be set to global functions. I have followed all steps within the stm32cubemx guide on mathworks. Current information about how to set up in stm32cubemx: https://www.mathworks.com/help/supportpkg/stmicroelectronicsstm32f4discovery/ug/Getting-started-stm32cubemx.html.
Are there any guides on how to accomplish this appropriately or correctly within matlab/simulink environment, instead of what was recommended within the STM32 community here: https://community.st.com/t5/stm32cubemx-mcus/how-to-change-init-functions-to-global/td-p/53187. I drafted a simple function to update the init function-calls to be externs, not saying it couldnt be optimized, or improved (see attached). I believe this should enable building the simple example, however I still receive the same error when attempting to build code.
Current error when I attempt to build:
Every init function must be configured to generate a global function call instead of static functions call in STM32CubeMX project. I have been intermittently attempting to use a Arduino Giga R1 with Simulink. I have, to my knowledge setup a simple example within a STM32 ioc file (derived from this setup: https://github.com/szabo-tamas/GigaR1Init). However in the building process within Simulink, it fails due to init functions needing to be set to global functions. I have followed all steps within the stm32cubemx guide on mathworks. Current information about how to set up in stm32cubemx: https://www.mathworks.com/help/supportpkg/stmicroelectronicsstm32f4discovery/ug/Getting-started-stm32cubemx.html.
Are there any guides on how to accomplish this appropriately or correctly within matlab/simulink environment, instead of what was recommended within the STM32 community here: https://community.st.com/t5/stm32cubemx-mcus/how-to-change-init-functions-to-global/td-p/53187. I drafted a simple function to update the init function-calls to be externs, not saying it couldnt be optimized, or improved (see attached). I believe this should enable building the simple example, however I still receive the same error when attempting to build code.
Current error when I attempt to build:
Every init function must be configured to generate a global function call instead of static functions call in STM32CubeMX project. arduino, giga r1, stm32, stm32cubemx MATLAB Answers — New Questions
Create contour plot from scatter plot
I want to create a contour from this matrix with x,y and z data. x is the length, y is the width and z is the deviatoric strain.
I want to create a contour plot instead. Is that possible?
figure; hold on ; box on
scatter(x,y,[20],-z,’filled’)
ylabel(‘Width, $(mathrm{m})$’,’FontSize’,15); xlabel(‘Length, $(mathrm{m})$’,’FontSize’,15,’FontName’,’times’)I want to create a contour from this matrix with x,y and z data. x is the length, y is the width and z is the deviatoric strain.
I want to create a contour plot instead. Is that possible?
figure; hold on ; box on
scatter(x,y,[20],-z,’filled’)
ylabel(‘Width, $(mathrm{m})$’,’FontSize’,15); xlabel(‘Length, $(mathrm{m})$’,’FontSize’,15,’FontName’,’times’) I want to create a contour from this matrix with x,y and z data. x is the length, y is the width and z is the deviatoric strain.
I want to create a contour plot instead. Is that possible?
figure; hold on ; box on
scatter(x,y,[20],-z,’filled’)
ylabel(‘Width, $(mathrm{m})$’,’FontSize’,15); xlabel(‘Length, $(mathrm{m})$’,’FontSize’,15,’FontName’,’times’) contour plot MATLAB Answers — New Questions
One legend for a group of subtightplots
In the following plot, formed by 4 subtightplots, how can I have just one (outside) legend for the left plots, and just one right (outside) legend for the right plots?
addpath(‘/…/subtightplot’);
subplot = @(m,n,p) subtightplot (m, n, p, [0.03 0], [0.04 0.03], [0.06 0.06]);
figure(‘position’,[700 100 1200 1200],’Color’,[1 1 1]);
hold on
for i = 1 : 4
subplot(2,2,i);
if i == 1 || i == 3 %%% left plots
hold on
t = 0:1:10;
plot(t,20.*cos(t),’^–‘,’LineWidth’,1,’Color’,’b’)
plot(1:10,(1:10).^2,’^–‘,’LineWidth’,1,’Color’,’k’)
plot(1:10,(1:10).^2.3,’^–‘,’LineWidth’,1,’Color’,’g’)
hold off
else %%% right plots
hold on
plot(1:10,randi([-50,50],10,1),’o-‘,’LineWidth’,1,’Color’,’r’)
plot(1:10,randi([-50,50],10,1),’o-‘,’LineWidth’,1,’Color’,’m’)
plot(1:10,randi([-50,50],10,1),’o-‘,’LineWidth’,1,’Color’,’y’)
hold off
end
legend(‘Box’,’off’);
end
hold off
This is the my desired result:In the following plot, formed by 4 subtightplots, how can I have just one (outside) legend for the left plots, and just one right (outside) legend for the right plots?
addpath(‘/…/subtightplot’);
subplot = @(m,n,p) subtightplot (m, n, p, [0.03 0], [0.04 0.03], [0.06 0.06]);
figure(‘position’,[700 100 1200 1200],’Color’,[1 1 1]);
hold on
for i = 1 : 4
subplot(2,2,i);
if i == 1 || i == 3 %%% left plots
hold on
t = 0:1:10;
plot(t,20.*cos(t),’^–‘,’LineWidth’,1,’Color’,’b’)
plot(1:10,(1:10).^2,’^–‘,’LineWidth’,1,’Color’,’k’)
plot(1:10,(1:10).^2.3,’^–‘,’LineWidth’,1,’Color’,’g’)
hold off
else %%% right plots
hold on
plot(1:10,randi([-50,50],10,1),’o-‘,’LineWidth’,1,’Color’,’r’)
plot(1:10,randi([-50,50],10,1),’o-‘,’LineWidth’,1,’Color’,’m’)
plot(1:10,randi([-50,50],10,1),’o-‘,’LineWidth’,1,’Color’,’y’)
hold off
end
legend(‘Box’,’off’);
end
hold off
This is the my desired result: In the following plot, formed by 4 subtightplots, how can I have just one (outside) legend for the left plots, and just one right (outside) legend for the right plots?
addpath(‘/…/subtightplot’);
subplot = @(m,n,p) subtightplot (m, n, p, [0.03 0], [0.04 0.03], [0.06 0.06]);
figure(‘position’,[700 100 1200 1200],’Color’,[1 1 1]);
hold on
for i = 1 : 4
subplot(2,2,i);
if i == 1 || i == 3 %%% left plots
hold on
t = 0:1:10;
plot(t,20.*cos(t),’^–‘,’LineWidth’,1,’Color’,’b’)
plot(1:10,(1:10).^2,’^–‘,’LineWidth’,1,’Color’,’k’)
plot(1:10,(1:10).^2.3,’^–‘,’LineWidth’,1,’Color’,’g’)
hold off
else %%% right plots
hold on
plot(1:10,randi([-50,50],10,1),’o-‘,’LineWidth’,1,’Color’,’r’)
plot(1:10,randi([-50,50],10,1),’o-‘,’LineWidth’,1,’Color’,’m’)
plot(1:10,randi([-50,50],10,1),’o-‘,’LineWidth’,1,’Color’,’y’)
hold off
end
legend(‘Box’,’off’);
end
hold off
This is the my desired result: legend, subtightplot MATLAB Answers — New Questions
How can I write a set of first order ODEs with two variables?
Hi, my assignment asks me to convert the following two 2nd order ODE’s to a system of four 1st order ODEs and then encode the equations in a function to then use with ODE45.
The two 2nd order ODE’s are as follows:
Then I converted them to a system of four 1st order ODEs (I think I did this correctly):
y’ = v
x’ = u
u’ = -(D/m)*u*sqrt(u^2+v^2)
v’ = -g-(D/m)*v*sqrt(u^2+v^2)
Then, I’ve been looking at this page as a reference for writing the system in my code. But, I’m confused as to how to write it when there are two different equations that use both x and y. The problem does say to slit the equations into several first order ODE’s in terms of the values of y. Thank you!!Hi, my assignment asks me to convert the following two 2nd order ODE’s to a system of four 1st order ODEs and then encode the equations in a function to then use with ODE45.
The two 2nd order ODE’s are as follows:
Then I converted them to a system of four 1st order ODEs (I think I did this correctly):
y’ = v
x’ = u
u’ = -(D/m)*u*sqrt(u^2+v^2)
v’ = -g-(D/m)*v*sqrt(u^2+v^2)
Then, I’ve been looking at this page as a reference for writing the system in my code. But, I’m confused as to how to write it when there are two different equations that use both x and y. The problem does say to slit the equations into several first order ODE’s in terms of the values of y. Thank you!! Hi, my assignment asks me to convert the following two 2nd order ODE’s to a system of four 1st order ODEs and then encode the equations in a function to then use with ODE45.
The two 2nd order ODE’s are as follows:
Then I converted them to a system of four 1st order ODEs (I think I did this correctly):
y’ = v
x’ = u
u’ = -(D/m)*u*sqrt(u^2+v^2)
v’ = -g-(D/m)*v*sqrt(u^2+v^2)
Then, I’ve been looking at this page as a reference for writing the system in my code. But, I’m confused as to how to write it when there are two different equations that use both x and y. The problem does say to slit the equations into several first order ODE’s in terms of the values of y. Thank you!! ode, ode45 MATLAB Answers — New Questions
Field Value Guage widgets are blank
I have a set of plots and guages set up using the widgets. Last year they all worked. Now the plots work fine but the Field Guage Widgets are blank. I can create a Numeric Display widget and that works. But if I create a new Field Guage Widget (dial) it is blank. I get the outline of the display window but nothing shows up inside the window. Are guages still supported?I have a set of plots and guages set up using the widgets. Last year they all worked. Now the plots work fine but the Field Guage Widgets are blank. I can create a Numeric Display widget and that works. But if I create a new Field Guage Widget (dial) it is blank. I get the outline of the display window but nothing shows up inside the window. Are guages still supported? I have a set of plots and guages set up using the widgets. Last year they all worked. Now the plots work fine but the Field Guage Widgets are blank. I can create a Numeric Display widget and that works. But if I create a new Field Guage Widget (dial) it is blank. I get the outline of the display window but nothing shows up inside the window. Are guages still supported? guage, widget MATLAB Answers — New Questions
How to setup gamultiobj to “explore farther” along a specific objective?
Overview: This question deals with a scenario where one of the objectives is "more important" than another, and we want the Pareto front to "mostly minimize" the important objective and have a large variability along the unimportant one.
Background: I am dealing with an optimization problem that consists of one "important" objective, and another "unimportant" one. Initially, it started out as single-objective optimization, but it produced results that "didn’t make sense". In response, I’ve introduced a second objective, so as to keep the first one in check. However, I’m mainly interested in solutions that minimize the original objective. To put this graphically, let’s say that this is the current output:
where Objective 1 is the important objective and Objective 2 is the unimportant one. I’m more interested in the vertical region (where Obj1 is minimized) at the expense of the horizontal region. In other words, I’m interested in what is happening for Obj2 < 16.6, but instead I’m seeing Obj2>17, which I don’t really care about.
I have a feeling that the optimization options can somehow help in getting the desired result, though playing around with various settings of optimopts(@gamultiobj, …) (such as ParetoFraction and DistanceMeasureFcn), I couldn’t get it to work.
My question is: How to set up the multi-objective GA optimization problem, such that more of the pareto is explored in a specific direction (while sacrificing the resolution and/or the distance along the other direction)? Alternatively, how to have more of the pareto explored in both directions (while sacrificing the resolution).
P.S.
I am aware of the possibility of defining a single objective that is a weighted sum of the present objectives, which would turn this into a question of choosing an appropriate weighting. However, this would be a last resort for me, so I would rather keep it as a multiple-objective problem.
P.S. 2
I am sure that solutions exist in the desired (unexplored) region.Overview: This question deals with a scenario where one of the objectives is "more important" than another, and we want the Pareto front to "mostly minimize" the important objective and have a large variability along the unimportant one.
Background: I am dealing with an optimization problem that consists of one "important" objective, and another "unimportant" one. Initially, it started out as single-objective optimization, but it produced results that "didn’t make sense". In response, I’ve introduced a second objective, so as to keep the first one in check. However, I’m mainly interested in solutions that minimize the original objective. To put this graphically, let’s say that this is the current output:
where Objective 1 is the important objective and Objective 2 is the unimportant one. I’m more interested in the vertical region (where Obj1 is minimized) at the expense of the horizontal region. In other words, I’m interested in what is happening for Obj2 < 16.6, but instead I’m seeing Obj2>17, which I don’t really care about.
I have a feeling that the optimization options can somehow help in getting the desired result, though playing around with various settings of optimopts(@gamultiobj, …) (such as ParetoFraction and DistanceMeasureFcn), I couldn’t get it to work.
My question is: How to set up the multi-objective GA optimization problem, such that more of the pareto is explored in a specific direction (while sacrificing the resolution and/or the distance along the other direction)? Alternatively, how to have more of the pareto explored in both directions (while sacrificing the resolution).
P.S.
I am aware of the possibility of defining a single objective that is a weighted sum of the present objectives, which would turn this into a question of choosing an appropriate weighting. However, this would be a last resort for me, so I would rather keep it as a multiple-objective problem.
P.S. 2
I am sure that solutions exist in the desired (unexplored) region. Overview: This question deals with a scenario where one of the objectives is "more important" than another, and we want the Pareto front to "mostly minimize" the important objective and have a large variability along the unimportant one.
Background: I am dealing with an optimization problem that consists of one "important" objective, and another "unimportant" one. Initially, it started out as single-objective optimization, but it produced results that "didn’t make sense". In response, I’ve introduced a second objective, so as to keep the first one in check. However, I’m mainly interested in solutions that minimize the original objective. To put this graphically, let’s say that this is the current output:
where Objective 1 is the important objective and Objective 2 is the unimportant one. I’m more interested in the vertical region (where Obj1 is minimized) at the expense of the horizontal region. In other words, I’m interested in what is happening for Obj2 < 16.6, but instead I’m seeing Obj2>17, which I don’t really care about.
I have a feeling that the optimization options can somehow help in getting the desired result, though playing around with various settings of optimopts(@gamultiobj, …) (such as ParetoFraction and DistanceMeasureFcn), I couldn’t get it to work.
My question is: How to set up the multi-objective GA optimization problem, such that more of the pareto is explored in a specific direction (while sacrificing the resolution and/or the distance along the other direction)? Alternatively, how to have more of the pareto explored in both directions (while sacrificing the resolution).
P.S.
I am aware of the possibility of defining a single objective that is a weighted sum of the present objectives, which would turn this into a question of choosing an appropriate weighting. However, this would be a last resort for me, so I would rather keep it as a multiple-objective problem.
P.S. 2
I am sure that solutions exist in the desired (unexplored) region. ga, gamultiobj, pareto-front MATLAB Answers — New Questions
how to fix these code lines for app designer
e gaussian and periodic noise this is my code for them and they didnt work how can i fix them plz?
this is the gaussina noise code
a=(app.Image);
noise=imnoise(a,’gaussian’);
I=imshow(noise,’parent’,app.UIAxes2,…
‘XData’,[1 app.UIAxes2.Position(3)],…
‘YData’,[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2)];
and this the periodic noise code
a=(app.Image);
s=size(a);
[x,y]=meshgrid(1:s(1),1:s(2));
p=sin(x/3+y/5)+1;
noise=(im2double(a)+p/2)/2;
I=imshow(noise,’parent’,app.UIAxes2,…
‘XData’,[1 app.UIAxes2.Position(3)],…
‘YData’,[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2)];
i also have this low pass filter also doesnt work how can i fix it
a=(app.Image);
f1=fspecial(‘average’,[5,5]);
I=imshow(f1,’parent’,app.UIAxes2,…
‘XData’,[1 app.UIAxes2.Position(3)],…
‘YData’,[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2e gaussian and periodic noise this is my code for them and they didnt work how can i fix them plz?
this is the gaussina noise code
a=(app.Image);
noise=imnoise(a,’gaussian’);
I=imshow(noise,’parent’,app.UIAxes2,…
‘XData’,[1 app.UIAxes2.Position(3)],…
‘YData’,[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2)];
and this the periodic noise code
a=(app.Image);
s=size(a);
[x,y]=meshgrid(1:s(1),1:s(2));
p=sin(x/3+y/5)+1;
noise=(im2double(a)+p/2)/2;
I=imshow(noise,’parent’,app.UIAxes2,…
‘XData’,[1 app.UIAxes2.Position(3)],…
‘YData’,[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2)];
i also have this low pass filter also doesnt work how can i fix it
a=(app.Image);
f1=fspecial(‘average’,[5,5]);
I=imshow(f1,’parent’,app.UIAxes2,…
‘XData’,[1 app.UIAxes2.Position(3)],…
‘YData’,[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2 e gaussian and periodic noise this is my code for them and they didnt work how can i fix them plz?
this is the gaussina noise code
a=(app.Image);
noise=imnoise(a,’gaussian’);
I=imshow(noise,’parent’,app.UIAxes2,…
‘XData’,[1 app.UIAxes2.Position(3)],…
‘YData’,[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2)];
and this the periodic noise code
a=(app.Image);
s=size(a);
[x,y]=meshgrid(1:s(1),1:s(2));
p=sin(x/3+y/5)+1;
noise=(im2double(a)+p/2)/2;
I=imshow(noise,’parent’,app.UIAxes2,…
‘XData’,[1 app.UIAxes2.Position(3)],…
‘YData’,[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2)];
i also have this low pass filter also doesnt work how can i fix it
a=(app.Image);
f1=fspecial(‘average’,[5,5]);
I=imshow(f1,’parent’,app.UIAxes2,…
‘XData’,[1 app.UIAxes2.Position(3)],…
‘YData’,[1 app.UIAxes2.Position(4)]);
app.UIAxes2.XLim=[0 I.XData(2)];
app.UIAxes2.YLim=[0 I.YData(2 #appdesigner #library MATLAB Answers — New Questions
Import data from *.ch file
Hello – has anyone ever tried to import gas chromatograph data from files with .ch extension?Hello – has anyone ever tried to import gas chromatograph data from files with .ch extension? Hello – has anyone ever tried to import gas chromatograph data from files with .ch extension? chromatogram, import, data MATLAB Answers — New Questions
How to generate IP block from QAM receiver example?
I want to generate an IP block from the QAM receiver part from this example:
https://www.mathworks.com/help/comm/ug/hdl-optimized-qam-transmitter-and-receiver.html?searchHighlight=hdl%20qam64&s_tid=srchtitle_support_results_1_hdl%20qam64
To generate an IP core with AXI-stream slave interface using HDL coder it is necessary to specify the valid signal. I do not know what is the right approach to address this.
The model contains a rate transition (there is decimation filter in the Coarse Frequency
Offset Correction ) so it is not possible just wrap the whole system into one enabled subsystem, how it is suggested in this example:
https://www.mathworks.com/help/hdlcoder/ug/model-design-for-axi4-stream-interface-generation.html
How to handle the valid-in signal? Should I split the model to two (or more) enabled submodels before and after the rate transition? Should I manually downsample the valid signal using the downsample block and use the right number of delays to synchronize it?
Is the example just a demonstration of the HDL libraries that nobody intended to use for HDL code generation? What do I miss?I want to generate an IP block from the QAM receiver part from this example:
https://www.mathworks.com/help/comm/ug/hdl-optimized-qam-transmitter-and-receiver.html?searchHighlight=hdl%20qam64&s_tid=srchtitle_support_results_1_hdl%20qam64
To generate an IP core with AXI-stream slave interface using HDL coder it is necessary to specify the valid signal. I do not know what is the right approach to address this.
The model contains a rate transition (there is decimation filter in the Coarse Frequency
Offset Correction ) so it is not possible just wrap the whole system into one enabled subsystem, how it is suggested in this example:
https://www.mathworks.com/help/hdlcoder/ug/model-design-for-axi4-stream-interface-generation.html
How to handle the valid-in signal? Should I split the model to two (or more) enabled submodels before and after the rate transition? Should I manually downsample the valid signal using the downsample block and use the right number of delays to synchronize it?
Is the example just a demonstration of the HDL libraries that nobody intended to use for HDL code generation? What do I miss? I want to generate an IP block from the QAM receiver part from this example:
https://www.mathworks.com/help/comm/ug/hdl-optimized-qam-transmitter-and-receiver.html?searchHighlight=hdl%20qam64&s_tid=srchtitle_support_results_1_hdl%20qam64
To generate an IP core with AXI-stream slave interface using HDL coder it is necessary to specify the valid signal. I do not know what is the right approach to address this.
The model contains a rate transition (there is decimation filter in the Coarse Frequency
Offset Correction ) so it is not possible just wrap the whole system into one enabled subsystem, how it is suggested in this example:
https://www.mathworks.com/help/hdlcoder/ug/model-design-for-axi4-stream-interface-generation.html
How to handle the valid-in signal? Should I split the model to two (or more) enabled submodels before and after the rate transition? Should I manually downsample the valid signal using the downsample block and use the right number of delays to synchronize it?
Is the example just a demonstration of the HDL libraries that nobody intended to use for HDL code generation? What do I miss? qam, axi-stream, multirate, hdl coder, valid signal MATLAB Answers — New Questions
Disappointment with change to section highlighting and run section capability in MATLAB functions after MATLAB 2020b
There is significant information on MATLAB central about this topic already. Here’s a typical question, paraphrased by me:
I recently upgraded from MATLAB 2020b to MATLAB 2023b. I can no longer highlight sections nor can I run sections. How can I recover the old capability?
Here’s my answer:
The new highlighting and run section capability is limited to scripts, not functions in the newer versions of MATLAB! Even with scripts, highlighting requires that one right-click on the left margin (the one with the line numbers) and ensure "Show code folding margin" is enabled with a check mark. This allows a blue bar to be displayed in the margin of the current section (that is, the one in which the cursor appears). The section can be run using either the menu or by clicking the blue bar. But only in scripts, not functions!
Here’s are my disappointments:
In the older versions, I really appreciated the ability to highlight the current section. I prefer to write functions rather than scripts, because I frequently build them into larger MATLAB systems. The new suppression of the old highlighting capability in functions is a real loss to me — the instant visibility of the current section was very valuable.
Similarly, the inability to run sections in functions is a loss of capability. I did not use it frequently, but many of my colleagues use it all the time. Now when they help work on my codes, they won’t have that capability.
This seemed like a needless loss of capability in an upgrade to the (relatively expensive) software development system that MATLAB represents.
The native MATLAB documentation on this is dreadfully lacking. I have spent hours getting to the bottom of this, searching every menu, preference list, and MATLAB Central posting I can find, to no avail.
The MATLAB Central documentation is all over the map, and there don’t seem to be very clear answers anywhere. (I hope this posting helps.)
Here are my recommendations:
Please restore the highlighting and run section capability for functions in the next MATLAB release!
I far prefer block coloring of the current section than the blue bar. I don’t like the extra margin width required by the code folding margin, and I find the blue bar less visible than coloring of the section.
At minimum, all of this should be tailorable as user options.
Thank you.There is significant information on MATLAB central about this topic already. Here’s a typical question, paraphrased by me:
I recently upgraded from MATLAB 2020b to MATLAB 2023b. I can no longer highlight sections nor can I run sections. How can I recover the old capability?
Here’s my answer:
The new highlighting and run section capability is limited to scripts, not functions in the newer versions of MATLAB! Even with scripts, highlighting requires that one right-click on the left margin (the one with the line numbers) and ensure "Show code folding margin" is enabled with a check mark. This allows a blue bar to be displayed in the margin of the current section (that is, the one in which the cursor appears). The section can be run using either the menu or by clicking the blue bar. But only in scripts, not functions!
Here’s are my disappointments:
In the older versions, I really appreciated the ability to highlight the current section. I prefer to write functions rather than scripts, because I frequently build them into larger MATLAB systems. The new suppression of the old highlighting capability in functions is a real loss to me — the instant visibility of the current section was very valuable.
Similarly, the inability to run sections in functions is a loss of capability. I did not use it frequently, but many of my colleagues use it all the time. Now when they help work on my codes, they won’t have that capability.
This seemed like a needless loss of capability in an upgrade to the (relatively expensive) software development system that MATLAB represents.
The native MATLAB documentation on this is dreadfully lacking. I have spent hours getting to the bottom of this, searching every menu, preference list, and MATLAB Central posting I can find, to no avail.
The MATLAB Central documentation is all over the map, and there don’t seem to be very clear answers anywhere. (I hope this posting helps.)
Here are my recommendations:
Please restore the highlighting and run section capability for functions in the next MATLAB release!
I far prefer block coloring of the current section than the blue bar. I don’t like the extra margin width required by the code folding margin, and I find the blue bar less visible than coloring of the section.
At minimum, all of this should be tailorable as user options.
Thank you. There is significant information on MATLAB central about this topic already. Here’s a typical question, paraphrased by me:
I recently upgraded from MATLAB 2020b to MATLAB 2023b. I can no longer highlight sections nor can I run sections. How can I recover the old capability?
Here’s my answer:
The new highlighting and run section capability is limited to scripts, not functions in the newer versions of MATLAB! Even with scripts, highlighting requires that one right-click on the left margin (the one with the line numbers) and ensure "Show code folding margin" is enabled with a check mark. This allows a blue bar to be displayed in the margin of the current section (that is, the one in which the cursor appears). The section can be run using either the menu or by clicking the blue bar. But only in scripts, not functions!
Here’s are my disappointments:
In the older versions, I really appreciated the ability to highlight the current section. I prefer to write functions rather than scripts, because I frequently build them into larger MATLAB systems. The new suppression of the old highlighting capability in functions is a real loss to me — the instant visibility of the current section was very valuable.
Similarly, the inability to run sections in functions is a loss of capability. I did not use it frequently, but many of my colleagues use it all the time. Now when they help work on my codes, they won’t have that capability.
This seemed like a needless loss of capability in an upgrade to the (relatively expensive) software development system that MATLAB represents.
The native MATLAB documentation on this is dreadfully lacking. I have spent hours getting to the bottom of this, searching every menu, preference list, and MATLAB Central posting I can find, to no avail.
The MATLAB Central documentation is all over the map, and there don’t seem to be very clear answers anywhere. (I hope this posting helps.)
Here are my recommendations:
Please restore the highlighting and run section capability for functions in the next MATLAB release!
I far prefer block coloring of the current section than the blue bar. I don’t like the extra margin width required by the code folding margin, and I find the blue bar less visible than coloring of the section.
At minimum, all of this should be tailorable as user options.
Thank you. highlight section, run section, function sections, script sections MATLAB Answers — New Questions
what is (data, event, message) in class and (input, output, local, constant, parameter and data store memory) in scope?
what is (data, event, message) in class and (input, output, local, constant, parameter and data store memory) in scope?what is (data, event, message) in class and (input, output, local, constant, parameter and data store memory) in scope? what is (data, event, message) in class and (input, output, local, constant, parameter and data store memory) in scope? stateflow, matlab MATLAB Answers — New Questions
Using quiver plot,how to show the states of polarization (SoP) in vector beams
As shown in the figure, I want to plot the polarization state of this radial or angular vector beam。As shown in the figure, I want to plot the polarization state of this radial or angular vector beam。 As shown in the figure, I want to plot the polarization state of this radial or angular vector beam。 vector beam, polarization MATLAB Answers — New Questions
Curve fitting with multiple variables?
I have three different curves for S=2, S=1 and S=0.5 as shown in Figure below. The Book1.xlsx is attached.
I want to use curve fitting to find out one common equation such as, HF = f(S,T).
I used the following comman line to get the equation which I got from previous post (link). But I am getting following error:
Error using nlinfit (line 213)
Error evaluating model function ‘@(b,x)exp(b(1)).*x(:,1).^b(2)+b(3).*x(:,2)
What should I do? Is there any other better method as well?
T1 = readtable(‘Book1.xlsx’, ‘VariableNamingRule’,’preserve’)
VN = T1.Properties.VariableNames
Viv = regexp([VN{:}], ‘(d*.d*)|d*’, ‘match’)
Viv = str2double(Viv)
Viym = T1{:,2:4};
Viyv = Viym(:); % ‘Vi’ Vector
Vivm = repmat(Viv, size(T1,1), 1);
Vivv = Vivm(:); % ‘Viv’ Vector
y = Viyv;
SoCv = repmat(T1.T, size(Viym,2), 1) % ‘SoC’ Vector
x = [SoCv Vivv]; % Concatenate Vectors
objfcn = @(b,x) exp(b(1)).*x(:,1).^b(2) + b(3).*x(:,2);
mdl = fitnlm(x, y, objfcn, rand(3,1))I have three different curves for S=2, S=1 and S=0.5 as shown in Figure below. The Book1.xlsx is attached.
I want to use curve fitting to find out one common equation such as, HF = f(S,T).
I used the following comman line to get the equation which I got from previous post (link). But I am getting following error:
Error using nlinfit (line 213)
Error evaluating model function ‘@(b,x)exp(b(1)).*x(:,1).^b(2)+b(3).*x(:,2)
What should I do? Is there any other better method as well?
T1 = readtable(‘Book1.xlsx’, ‘VariableNamingRule’,’preserve’)
VN = T1.Properties.VariableNames
Viv = regexp([VN{:}], ‘(d*.d*)|d*’, ‘match’)
Viv = str2double(Viv)
Viym = T1{:,2:4};
Viyv = Viym(:); % ‘Vi’ Vector
Vivm = repmat(Viv, size(T1,1), 1);
Vivv = Vivm(:); % ‘Viv’ Vector
y = Viyv;
SoCv = repmat(T1.T, size(Viym,2), 1) % ‘SoC’ Vector
x = [SoCv Vivv]; % Concatenate Vectors
objfcn = @(b,x) exp(b(1)).*x(:,1).^b(2) + b(3).*x(:,2);
mdl = fitnlm(x, y, objfcn, rand(3,1)) I have three different curves for S=2, S=1 and S=0.5 as shown in Figure below. The Book1.xlsx is attached.
I want to use curve fitting to find out one common equation such as, HF = f(S,T).
I used the following comman line to get the equation which I got from previous post (link). But I am getting following error:
Error using nlinfit (line 213)
Error evaluating model function ‘@(b,x)exp(b(1)).*x(:,1).^b(2)+b(3).*x(:,2)
What should I do? Is there any other better method as well?
T1 = readtable(‘Book1.xlsx’, ‘VariableNamingRule’,’preserve’)
VN = T1.Properties.VariableNames
Viv = regexp([VN{:}], ‘(d*.d*)|d*’, ‘match’)
Viv = str2double(Viv)
Viym = T1{:,2:4};
Viyv = Viym(:); % ‘Vi’ Vector
Vivm = repmat(Viv, size(T1,1), 1);
Vivv = Vivm(:); % ‘Viv’ Vector
y = Viyv;
SoCv = repmat(T1.T, size(Viym,2), 1) % ‘SoC’ Vector
x = [SoCv Vivv]; % Concatenate Vectors
objfcn = @(b,x) exp(b(1)).*x(:,1).^b(2) + b(3).*x(:,2);
mdl = fitnlm(x, y, objfcn, rand(3,1)) curve fitting, regression, interpolation, variables MATLAB Answers — New Questions
Image matrix codding with LDPC channel coding
I need to MATLAB function to convert an image into matrix and encode it with LDPC codding then need to modulate it with PSK modulationI need to MATLAB function to convert an image into matrix and encode it with LDPC codding then need to modulate it with PSK modulation I need to MATLAB function to convert an image into matrix and encode it with LDPC codding then need to modulate it with PSK modulation digital image processing, ldpc codding MATLAB Answers — New Questions
Plotting a diagram and getting some errors
Hi, I’m having an issue with my code. I’m trying to plot a basic diagram, but MATLAB is only giving me errors.Error massage is "
Undefined function ‘plotv’ for input arguments of type ‘double’." I’m wondering where I might be going wrong. My code looks like this:
x_1 = [-0.9487 ; 0.3162];
x_2 = [-0.2425 ; -0.9701];
u = x_1 + x_2;
A_u = A .* u;
A_2u = A^2 * u;
hold on
plotv(x_1,’r’);
plotv(x_2,’b’);
plotv(u,’k’);
plotv(A_u,’g’);
plotv(A_2u,’c’);
legend(‘x1′,’x2’, ‘u’, ‘Au’, ‘A^2u’);
hold offHi, I’m having an issue with my code. I’m trying to plot a basic diagram, but MATLAB is only giving me errors.Error massage is "
Undefined function ‘plotv’ for input arguments of type ‘double’." I’m wondering where I might be going wrong. My code looks like this:
x_1 = [-0.9487 ; 0.3162];
x_2 = [-0.2425 ; -0.9701];
u = x_1 + x_2;
A_u = A .* u;
A_2u = A^2 * u;
hold on
plotv(x_1,’r’);
plotv(x_2,’b’);
plotv(u,’k’);
plotv(A_u,’g’);
plotv(A_2u,’c’);
legend(‘x1′,’x2’, ‘u’, ‘Au’, ‘A^2u’);
hold off Hi, I’m having an issue with my code. I’m trying to plot a basic diagram, but MATLAB is only giving me errors.Error massage is "
Undefined function ‘plotv’ for input arguments of type ‘double’." I’m wondering where I might be going wrong. My code looks like this:
x_1 = [-0.9487 ; 0.3162];
x_2 = [-0.2425 ; -0.9701];
u = x_1 + x_2;
A_u = A .* u;
A_2u = A^2 * u;
hold on
plotv(x_1,’r’);
plotv(x_2,’b’);
plotv(u,’k’);
plotv(A_u,’g’);
plotv(A_2u,’c’);
legend(‘x1′,’x2’, ‘u’, ‘Au’, ‘A^2u’);
hold off plotting MATLAB Answers — New Questions
Reading existing function in MATLAB?
I have download some function of Matlab for my project work. Now when I am running that function then it is showing error
Error: >> stlRead
Execution of script stlRead as a function is not supported:
I:Python coding3dNew findingsvsangelidakisvsangelidakis-SHAPE-f97791alibstlToolsstlRead.m
Error in stlRead (line 1)
[v, f, n, name] = stlRead(‘aggregate_1.stl’);
I am attcahing the folder of the function.I have download some function of Matlab for my project work. Now when I am running that function then it is showing error
Error: >> stlRead
Execution of script stlRead as a function is not supported:
I:Python coding3dNew findingsvsangelidakisvsangelidakis-SHAPE-f97791alibstlToolsstlRead.m
Error in stlRead (line 1)
[v, f, n, name] = stlRead(‘aggregate_1.stl’);
I am attcahing the folder of the function. I have download some function of Matlab for my project work. Now when I am running that function then it is showing error
Error: >> stlRead
Execution of script stlRead as a function is not supported:
I:Python coding3dNew findingsvsangelidakisvsangelidakis-SHAPE-f97791alibstlToolsstlRead.m
Error in stlRead (line 1)
[v, f, n, name] = stlRead(‘aggregate_1.stl’);
I am attcahing the folder of the function. embedded matlab function, matlab function MATLAB Answers — New Questions
How to properly connect to TI F28025C for code generation and model debugging?
Hello All,
I’m trying to configure my TI LaunchPad with F28002x C2000. I constantly receive errors when trying to use the Monitor & Tune option (Hardware -> Run on Hardware -> Monitor & Tune) but my project/model won’t connect to my device. However, the project/model seems to work when I press the Build, Deploy, and Start button. What am I missing?
So far, it seems like I need to manually change some of the Hardware Settings to properly switch my device from ‘Boot-from-Flash’ to ‘Boot-from-SCI’ or to ‘Boot-from-Ram’. If so, then can someone please confirm this process?
System Info:
Matlab R2023b
Trying to run the following example: Parameter Tuning and Signal Logging with Serial Communication (c28x_serial_ext model)
All software requirements are met and properly installed
Device Info:
Using TI LaunchPad kit
Part no: LAUNCHXL-F280025C
Connecting to target device from my host PC to an on-board XDS110 Debug Probe through USB
Thank You,
RaulHello All,
I’m trying to configure my TI LaunchPad with F28002x C2000. I constantly receive errors when trying to use the Monitor & Tune option (Hardware -> Run on Hardware -> Monitor & Tune) but my project/model won’t connect to my device. However, the project/model seems to work when I press the Build, Deploy, and Start button. What am I missing?
So far, it seems like I need to manually change some of the Hardware Settings to properly switch my device from ‘Boot-from-Flash’ to ‘Boot-from-SCI’ or to ‘Boot-from-Ram’. If so, then can someone please confirm this process?
System Info:
Matlab R2023b
Trying to run the following example: Parameter Tuning and Signal Logging with Serial Communication (c28x_serial_ext model)
All software requirements are met and properly installed
Device Info:
Using TI LaunchPad kit
Part no: LAUNCHXL-F280025C
Connecting to target device from my host PC to an on-board XDS110 Debug Probe through USB
Thank You,
Raul Hello All,
I’m trying to configure my TI LaunchPad with F28002x C2000. I constantly receive errors when trying to use the Monitor & Tune option (Hardware -> Run on Hardware -> Monitor & Tune) but my project/model won’t connect to my device. However, the project/model seems to work when I press the Build, Deploy, and Start button. What am I missing?
So far, it seems like I need to manually change some of the Hardware Settings to properly switch my device from ‘Boot-from-Flash’ to ‘Boot-from-SCI’ or to ‘Boot-from-Ram’. If so, then can someone please confirm this process?
System Info:
Matlab R2023b
Trying to run the following example: Parameter Tuning and Signal Logging with Serial Communication (c28x_serial_ext model)
All software requirements are met and properly installed
Device Info:
Using TI LaunchPad kit
Part no: LAUNCHXL-F280025C
Connecting to target device from my host PC to an on-board XDS110 Debug Probe through USB
Thank You,
Raul connection issues, c28x_serial_ext, launchxl-f280025c, c2000, f280025c, f28002x MATLAB Answers — New Questions