Category: Matlab
Category Archives: Matlab
Generation of basic signals
I just need the code for generating the basic codes like unit step signal, unit impulse signal. unit ramp signal and the sine wave signal.I just need the code for generating the basic codes like unit step signal, unit impulse signal. unit ramp signal and the sine wave signal. I just need the code for generating the basic codes like unit step signal, unit impulse signal. unit ramp signal and the sine wave signal. code generation MATLAB Answers — New Questions
How to write to csv file in shortG format?
Hello,
I would like to save a Matlab table (first column strings, the rest are floating numbers) to a csv in the shortG format. I have set the format in my script and when I look at the table in the program, it looks just as it should. However, when I save the table to a csv file, the numbers increase their decimal places counts suddenly, forbidding numbers like -6.0247e-06 etc. How to overcome this, please?
Thank you all in advance.Hello,
I would like to save a Matlab table (first column strings, the rest are floating numbers) to a csv in the shortG format. I have set the format in my script and when I look at the table in the program, it looks just as it should. However, when I save the table to a csv file, the numbers increase their decimal places counts suddenly, forbidding numbers like -6.0247e-06 etc. How to overcome this, please?
Thank you all in advance. Hello,
I would like to save a Matlab table (first column strings, the rest are floating numbers) to a csv in the shortG format. I have set the format in my script and when I look at the table in the program, it looks just as it should. However, when I save the table to a csv file, the numbers increase their decimal places counts suddenly, forbidding numbers like -6.0247e-06 etc. How to overcome this, please?
Thank you all in advance. csv, matlab, shortg MATLAB Answers — New Questions
Ramp block having reset option
I would like to implement in simscape a kind of ramp block having reset option, thus that ramp would start rising from zero every time the reset is triggered. I’ve tried with resetable subsystem block but is of no helpfull.
Have u got any idea how to solve this?I would like to implement in simscape a kind of ramp block having reset option, thus that ramp would start rising from zero every time the reset is triggered. I’ve tried with resetable subsystem block but is of no helpfull.
Have u got any idea how to solve this? I would like to implement in simscape a kind of ramp block having reset option, thus that ramp would start rising from zero every time the reset is triggered. I’ve tried with resetable subsystem block but is of no helpfull.
Have u got any idea how to solve this? ramp block, resetable MATLAB Answers — New Questions
Divide connected regions in an image into sub-groups
I have an image (attached as Picture1.png) where the multiple white thick lines are present both in horizontal and vertical directions.
The white lines (either vertical or horizontal) are not always straight and can be curved as shown in picture1. Now, I wish to divide these connected white regions into sub groups, as shown in picture 2. The vertical lines shouldnt undergo fragmentation when criss-crossed by the horizontal lines. Since all the white lines are interconnected to each other, I cannot use regionprops and other similar functions. The numbering of the sub-groups does not need to be in same order as shown in picture 2.
What can be done next? Thank youI have an image (attached as Picture1.png) where the multiple white thick lines are present both in horizontal and vertical directions.
The white lines (either vertical or horizontal) are not always straight and can be curved as shown in picture1. Now, I wish to divide these connected white regions into sub groups, as shown in picture 2. The vertical lines shouldnt undergo fragmentation when criss-crossed by the horizontal lines. Since all the white lines are interconnected to each other, I cannot use regionprops and other similar functions. The numbering of the sub-groups does not need to be in same order as shown in picture 2.
What can be done next? Thank you I have an image (attached as Picture1.png) where the multiple white thick lines are present both in horizontal and vertical directions.
The white lines (either vertical or horizontal) are not always straight and can be curved as shown in picture1. Now, I wish to divide these connected white regions into sub groups, as shown in picture 2. The vertical lines shouldnt undergo fragmentation when criss-crossed by the horizontal lines. Since all the white lines are interconnected to each other, I cannot use regionprops and other similar functions. The numbering of the sub-groups does not need to be in same order as shown in picture 2.
What can be done next? Thank you image processing, image segmentation MATLAB Answers — New Questions
Error with the animation of the surface plot
Hello
I want to perform a surface animation, but I constantly run into an error
Error using surf
Data dimensions must agree.
Error in surfc (line 54)
hs = surf(cax, args{:});
Error in dcSQUID_diode_efficiency_animation (line 26)
surfc(phi,theta,eff)
I would be grateful if someone could tell me where exactly I made a mistake in the code
function z1=dcSQUID_diode_efficiency_animation
tic
phi0=linspace(0.000,2*pi,100);
theta0=linspace(0.000,2*pi,100);
flux1=linspace(0,1,10);
h = figure;
axis tight manual
filename = ‘dc_squid_eff.gif’;
for ii = 1:10
for i=1:100
for j=1:100
y=self11(phi0(i),theta0(j),flux1(ii));
eff(i,j,ii)=y;
end
end
[phi,theta]=meshgrid(phi0,theta0);
surfc(phi,theta,eff)
zlim([-0.5 0.5])
clim([-0.5 0.5])
colormap jet
colorbar(‘FontSize’,34,’FontName’,’Times New Roman’)
set(gca,’FontName’,’Times New Roman’,’FontSize’,34)
xlabel(‘phi’,’FontName’,’Times New Roman’,’fontsize’,34,’fontweight’,’b’);
ylabel(‘theta’,’FontName’,’Times New Roman’,’fontsize’,34,’fontweight’,’b’);
set(gca,’XTick’,0:pi/2:2*pi)
set(gca,’XTickLabel’,{‘0′,’pi/2′,’pi’,’3pi/2′,’2pi’})
set(gca,’YTick’,0:pi/2:2*pi)
set(gca,’YTickLabel’,{‘0′,’pi/2′,’pi’,’3pi/2′,’2pi’})
drawnow
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if ii == 1
imwrite(imind,cm,filename,’gif’, ‘Loopcount’,inf);
else
imwrite(imind,cm,filename,’gif’,’WriteMode’,’append’);
end
end
function z2=self11(phi0,theta0,flux1)
rL1=1;
rL2=1;
rR0=1;
rR1=1;
rR2=1;
x = -2*pi:0.001:2*pi;
I_dc = cos(x./2).*atanh(sin(x./2))+rL1*cos((x+2*phi0)./2).*atanh(sin((x+2*phi0)./2))+rL2*cos((x+2*theta0)./2).*atanh(sin((x+2*theta0)./2))+…
rR0*cos((x-2*pi*flux1)./2).*atanh(sin((x-2*pi*flux1)./2))+rR1*cos(((x-2*pi*flux1)+2*phi0)./2).*atanh(sin(((x-2*pi*flux1)+2*phi0)./2))+…
rR2*cos(((x-2*pi*flux1)+2*theta0)./2).*atanh(sin(((x-2*pi*flux1)+2*theta0)./2));
I_min=min(I_dc);
I_max=max(I_dc);
z2=(I_max-abs(I_min))/(I_max+abs(I_min));
end
toc
endHello
I want to perform a surface animation, but I constantly run into an error
Error using surf
Data dimensions must agree.
Error in surfc (line 54)
hs = surf(cax, args{:});
Error in dcSQUID_diode_efficiency_animation (line 26)
surfc(phi,theta,eff)
I would be grateful if someone could tell me where exactly I made a mistake in the code
function z1=dcSQUID_diode_efficiency_animation
tic
phi0=linspace(0.000,2*pi,100);
theta0=linspace(0.000,2*pi,100);
flux1=linspace(0,1,10);
h = figure;
axis tight manual
filename = ‘dc_squid_eff.gif’;
for ii = 1:10
for i=1:100
for j=1:100
y=self11(phi0(i),theta0(j),flux1(ii));
eff(i,j,ii)=y;
end
end
[phi,theta]=meshgrid(phi0,theta0);
surfc(phi,theta,eff)
zlim([-0.5 0.5])
clim([-0.5 0.5])
colormap jet
colorbar(‘FontSize’,34,’FontName’,’Times New Roman’)
set(gca,’FontName’,’Times New Roman’,’FontSize’,34)
xlabel(‘phi’,’FontName’,’Times New Roman’,’fontsize’,34,’fontweight’,’b’);
ylabel(‘theta’,’FontName’,’Times New Roman’,’fontsize’,34,’fontweight’,’b’);
set(gca,’XTick’,0:pi/2:2*pi)
set(gca,’XTickLabel’,{‘0′,’pi/2′,’pi’,’3pi/2′,’2pi’})
set(gca,’YTick’,0:pi/2:2*pi)
set(gca,’YTickLabel’,{‘0′,’pi/2′,’pi’,’3pi/2′,’2pi’})
drawnow
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if ii == 1
imwrite(imind,cm,filename,’gif’, ‘Loopcount’,inf);
else
imwrite(imind,cm,filename,’gif’,’WriteMode’,’append’);
end
end
function z2=self11(phi0,theta0,flux1)
rL1=1;
rL2=1;
rR0=1;
rR1=1;
rR2=1;
x = -2*pi:0.001:2*pi;
I_dc = cos(x./2).*atanh(sin(x./2))+rL1*cos((x+2*phi0)./2).*atanh(sin((x+2*phi0)./2))+rL2*cos((x+2*theta0)./2).*atanh(sin((x+2*theta0)./2))+…
rR0*cos((x-2*pi*flux1)./2).*atanh(sin((x-2*pi*flux1)./2))+rR1*cos(((x-2*pi*flux1)+2*phi0)./2).*atanh(sin(((x-2*pi*flux1)+2*phi0)./2))+…
rR2*cos(((x-2*pi*flux1)+2*theta0)./2).*atanh(sin(((x-2*pi*flux1)+2*theta0)./2));
I_min=min(I_dc);
I_max=max(I_dc);
z2=(I_max-abs(I_min))/(I_max+abs(I_min));
end
toc
end Hello
I want to perform a surface animation, but I constantly run into an error
Error using surf
Data dimensions must agree.
Error in surfc (line 54)
hs = surf(cax, args{:});
Error in dcSQUID_diode_efficiency_animation (line 26)
surfc(phi,theta,eff)
I would be grateful if someone could tell me where exactly I made a mistake in the code
function z1=dcSQUID_diode_efficiency_animation
tic
phi0=linspace(0.000,2*pi,100);
theta0=linspace(0.000,2*pi,100);
flux1=linspace(0,1,10);
h = figure;
axis tight manual
filename = ‘dc_squid_eff.gif’;
for ii = 1:10
for i=1:100
for j=1:100
y=self11(phi0(i),theta0(j),flux1(ii));
eff(i,j,ii)=y;
end
end
[phi,theta]=meshgrid(phi0,theta0);
surfc(phi,theta,eff)
zlim([-0.5 0.5])
clim([-0.5 0.5])
colormap jet
colorbar(‘FontSize’,34,’FontName’,’Times New Roman’)
set(gca,’FontName’,’Times New Roman’,’FontSize’,34)
xlabel(‘phi’,’FontName’,’Times New Roman’,’fontsize’,34,’fontweight’,’b’);
ylabel(‘theta’,’FontName’,’Times New Roman’,’fontsize’,34,’fontweight’,’b’);
set(gca,’XTick’,0:pi/2:2*pi)
set(gca,’XTickLabel’,{‘0′,’pi/2′,’pi’,’3pi/2′,’2pi’})
set(gca,’YTick’,0:pi/2:2*pi)
set(gca,’YTickLabel’,{‘0′,’pi/2′,’pi’,’3pi/2′,’2pi’})
drawnow
frame = getframe(h);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if ii == 1
imwrite(imind,cm,filename,’gif’, ‘Loopcount’,inf);
else
imwrite(imind,cm,filename,’gif’,’WriteMode’,’append’);
end
end
function z2=self11(phi0,theta0,flux1)
rL1=1;
rL2=1;
rR0=1;
rR1=1;
rR2=1;
x = -2*pi:0.001:2*pi;
I_dc = cos(x./2).*atanh(sin(x./2))+rL1*cos((x+2*phi0)./2).*atanh(sin((x+2*phi0)./2))+rL2*cos((x+2*theta0)./2).*atanh(sin((x+2*theta0)./2))+…
rR0*cos((x-2*pi*flux1)./2).*atanh(sin((x-2*pi*flux1)./2))+rR1*cos(((x-2*pi*flux1)+2*phi0)./2).*atanh(sin(((x-2*pi*flux1)+2*phi0)./2))+…
rR2*cos(((x-2*pi*flux1)+2*theta0)./2).*atanh(sin(((x-2*pi*flux1)+2*theta0)./2));
I_min=min(I_dc);
I_max=max(I_dc);
z2=(I_max-abs(I_min))/(I_max+abs(I_min));
end
toc
end surface plot, animation MATLAB Answers — New Questions
Why do I get “Error: The server response timed out” every time I try to review results in the Polyspace Access Web UI?
I installed and started Polyspace Access, and provided the path to the license file in the "Configure Apps" menu within the Cluster Admin dashboard.
I clicked "Restart Apps" and all the apps are running including the Polyspace Access UI, and I uploaded results to Polyspace Access. I can see the results listed in the web UI, but when I try to review the results I get "Error:The server response timed out" every time.
There is no attempted license checkout https://www.mathworks.com/help/polyspace_access/install/configure-polyspace-access-license.html in the license manager debug log file.I installed and started Polyspace Access, and provided the path to the license file in the "Configure Apps" menu within the Cluster Admin dashboard.
I clicked "Restart Apps" and all the apps are running including the Polyspace Access UI, and I uploaded results to Polyspace Access. I can see the results listed in the web UI, but when I try to review the results I get "Error:The server response timed out" every time.
There is no attempted license checkout https://www.mathworks.com/help/polyspace_access/install/configure-polyspace-access-license.html in the license manager debug log file. I installed and started Polyspace Access, and provided the path to the license file in the "Configure Apps" menu within the Cluster Admin dashboard.
I clicked "Restart Apps" and all the apps are running including the Polyspace Access UI, and I uploaded results to Polyspace Access. I can see the results listed in the web UI, but when I try to review the results I get "Error:The server response timed out" every time.
There is no attempted license checkout https://www.mathworks.com/help/polyspace_access/install/configure-polyspace-access-license.html in the license manager debug log file. MATLAB Answers — New Questions
How Do I Create My Own Hardware Support Package?
I have hardware that I would like to target from MATLAB/Simulink. What resources are available for creating my own hardware support package?I have hardware that I would like to target from MATLAB/Simulink. What resources are available for creating my own hardware support package? I have hardware that I would like to target from MATLAB/Simulink. What resources are available for creating my own hardware support package? hardware, support, embedded, coder, simulink, driver, system MATLAB Answers — New Questions
Mathlab doesn’t show Graph
Can someone tell me why my matlab doesn’t show the graph?I’m getting the results i want but it doesn’t show the graph.
Thanks !Can someone tell me why my matlab doesn’t show the graph?I’m getting the results i want but it doesn’t show the graph.
Thanks ! Can someone tell me why my matlab doesn’t show the graph?I’m getting the results i want but it doesn’t show the graph.
Thanks ! graph, error MATLAB Answers — New Questions
Is the code repo for “co-simulate with unity and matlab” in the seminar “Design and Simulation of Autonomous Surface Vessels (ASV)” available?
The seminar and some GitHub websites are as follows: https://www.mathworks.com/matlabcentral/fileexchange/118968-simulate-navigation-algorithms-of-an-asv
https://github.com/MartinJXLuo/Simulate-Navigation-Algorithms-of-An-Autonomous-Surface-Vessel-ASV-
But it seems that some of the code associated with Unity has not been published by the author yet?The seminar and some GitHub websites are as follows: https://www.mathworks.com/matlabcentral/fileexchange/118968-simulate-navigation-algorithms-of-an-asv
https://github.com/MartinJXLuo/Simulate-Navigation-Algorithms-of-An-Autonomous-Surface-Vessel-ASV-
But it seems that some of the code associated with Unity has not been published by the author yet? The seminar and some GitHub websites are as follows: https://www.mathworks.com/matlabcentral/fileexchange/118968-simulate-navigation-algorithms-of-an-asv
https://github.com/MartinJXLuo/Simulate-Navigation-Algorithms-of-An-Autonomous-Surface-Vessel-ASV-
But it seems that some of the code associated with Unity has not been published by the author yet? uav,asv,unity MATLAB Answers — New Questions
reed solomon code over odd characteristic field
please help! how can i obtain a gen matrix and gen polynimial for reed solomon codes over odd characteristic field? all tolls that i found were intended for fields over GF(2^m).please help! how can i obtain a gen matrix and gen polynimial for reed solomon codes over odd characteristic field? all tolls that i found were intended for fields over GF(2^m). please help! how can i obtain a gen matrix and gen polynimial for reed solomon codes over odd characteristic field? all tolls that i found were intended for fields over GF(2^m). reed-solomon, rs MATLAB Answers — New Questions
How to use looping method to crop image dynamically (auto-cropping)?
Hello. How to crop image using dynamic cropping method in matlab? Is there any example implementation codes?
Lets say, my original image have two different sizes which are 482 x 841 pixels and 608 x 865 pixels, so can I use loop step at first to extend the pixels which those that not enough pixels if I want to crop into 512 x 512 pixels? If the image size is enough to crop into 512 x512 pixels so no need to extend the pixels. I recently use this code:-
%To read input image
I=imread(‘1_776.jpg’);
imfinfo(‘1_776.jpg’)
First image, image size 482 x 841 px
Second image, image size 608 x 865 px
%To resize image
out = padarray(I, [10 10], 0, ‘both’);
imshow(out);
imwrite(out,’resize1.jpg’);
but this is manual. Now I want it to automatically crop only specific area.Hello. How to crop image using dynamic cropping method in matlab? Is there any example implementation codes?
Lets say, my original image have two different sizes which are 482 x 841 pixels and 608 x 865 pixels, so can I use loop step at first to extend the pixels which those that not enough pixels if I want to crop into 512 x 512 pixels? If the image size is enough to crop into 512 x512 pixels so no need to extend the pixels. I recently use this code:-
%To read input image
I=imread(‘1_776.jpg’);
imfinfo(‘1_776.jpg’)
First image, image size 482 x 841 px
Second image, image size 608 x 865 px
%To resize image
out = padarray(I, [10 10], 0, ‘both’);
imshow(out);
imwrite(out,’resize1.jpg’);
but this is manual. Now I want it to automatically crop only specific area. Hello. How to crop image using dynamic cropping method in matlab? Is there any example implementation codes?
Lets say, my original image have two different sizes which are 482 x 841 pixels and 608 x 865 pixels, so can I use loop step at first to extend the pixels which those that not enough pixels if I want to crop into 512 x 512 pixels? If the image size is enough to crop into 512 x512 pixels so no need to extend the pixels. I recently use this code:-
%To read input image
I=imread(‘1_776.jpg’);
imfinfo(‘1_776.jpg’)
First image, image size 482 x 841 px
Second image, image size 608 x 865 px
%To resize image
out = padarray(I, [10 10], 0, ‘both’);
imshow(out);
imwrite(out,’resize1.jpg’);
but this is manual. Now I want it to automatically crop only specific area. loops MATLAB Answers — New Questions
My code is not working or MATLAB is not responding?
I’m currently working on designing a dynamic interface, which necessitates taking a cell array input from the user.
I’ve encountered an unexpected behavior while attempting this in MATLAB. Instead of storing the cell array in the workspace, the input statement appears multiple times in the command window.
Even when providing a normal numeric array like 1 2 3 4 5, it fails to work as expected.
surprisingly, there are no visible warnings or errors, leaving me uncertain whether there’s an issue with my code or if MATLAB itself is hanging.
Looking forward for assistance in resolving this issueI’m currently working on designing a dynamic interface, which necessitates taking a cell array input from the user.
I’ve encountered an unexpected behavior while attempting this in MATLAB. Instead of storing the cell array in the workspace, the input statement appears multiple times in the command window.
Even when providing a normal numeric array like 1 2 3 4 5, it fails to work as expected.
surprisingly, there are no visible warnings or errors, leaving me uncertain whether there’s an issue with my code or if MATLAB itself is hanging.
Looking forward for assistance in resolving this issue I’m currently working on designing a dynamic interface, which necessitates taking a cell array input from the user.
I’ve encountered an unexpected behavior while attempting this in MATLAB. Instead of storing the cell array in the workspace, the input statement appears multiple times in the command window.
Even when providing a normal numeric array like 1 2 3 4 5, it fails to work as expected.
surprisingly, there are no visible warnings or errors, leaving me uncertain whether there’s an issue with my code or if MATLAB itself is hanging.
Looking forward for assistance in resolving this issue matlab code, input MATLAB Answers — New Questions
How to Scale Gradient Field for large z-values?
I want to plot a function R^2 -> R with gradient Field beneath:
f2 = @(x,y) 1./sqrt(x.^2+y.^2);
[u2,v2] = meshgrid(-1:0.01:1);
[du2,dv2] = gradient(f2(u2,v2));
s = surf(u2,v2,f2(u2,v2));
hold on
contour(u2,v2,f2(u2,v2))
hold on
norm = 1./sqrt(du2.^2+dv2.^2);
quiver(u2,v2,du2./norm,dv2./norm,’LineWidth’,2)
axis([-1 1 -1 1 0 10])
caxis([0,10])
colormap(cool)
alpha(s,0.95)
shading flat
Sadly the gradient field is not visible. Probably because it’s too small, f2 get’s too large and I’m lacking of the mathmatical knowledge to adjust it properlyI want to plot a function R^2 -> R with gradient Field beneath:
f2 = @(x,y) 1./sqrt(x.^2+y.^2);
[u2,v2] = meshgrid(-1:0.01:1);
[du2,dv2] = gradient(f2(u2,v2));
s = surf(u2,v2,f2(u2,v2));
hold on
contour(u2,v2,f2(u2,v2))
hold on
norm = 1./sqrt(du2.^2+dv2.^2);
quiver(u2,v2,du2./norm,dv2./norm,’LineWidth’,2)
axis([-1 1 -1 1 0 10])
caxis([0,10])
colormap(cool)
alpha(s,0.95)
shading flat
Sadly the gradient field is not visible. Probably because it’s too small, f2 get’s too large and I’m lacking of the mathmatical knowledge to adjust it properly I want to plot a function R^2 -> R with gradient Field beneath:
f2 = @(x,y) 1./sqrt(x.^2+y.^2);
[u2,v2] = meshgrid(-1:0.01:1);
[du2,dv2] = gradient(f2(u2,v2));
s = surf(u2,v2,f2(u2,v2));
hold on
contour(u2,v2,f2(u2,v2))
hold on
norm = 1./sqrt(du2.^2+dv2.^2);
quiver(u2,v2,du2./norm,dv2./norm,’LineWidth’,2)
axis([-1 1 -1 1 0 10])
caxis([0,10])
colormap(cool)
alpha(s,0.95)
shading flat
Sadly the gradient field is not visible. Probably because it’s too small, f2 get’s too large and I’m lacking of the mathmatical knowledge to adjust it properly gradient MATLAB Answers — New Questions
How to import 2D finite element data from Matlab to Paraview?
Hello everyone!
I have 2D finite element data that are generated in matlab and I am trying to use this code for post-processing in Paraview:
https://www.mathworks.com/matlabcentral/fileexchange/47814-vtkwrite-exports-various-2d-3d-data-to-paraview-in-vtk-file-format.
I have the following matrices:
1) CRD(# of nodes, 2) which gives the 2D coordinates of the nodes,
2) Nodes(# of nodes per element,# of elements) which provides the connectivity between the nodes,
3) U(# of nodes, 2) which gives the x & y velocities per node, and
4) P(# of nodes, 1) which gives the pressure on a node.
However, I am not quite sure how can I put all these in the appropriate form so that they are compatible with the code. I went through several trials but it seems that the data are not saved properly. I would appreciate your help!Hello everyone!
I have 2D finite element data that are generated in matlab and I am trying to use this code for post-processing in Paraview:
https://www.mathworks.com/matlabcentral/fileexchange/47814-vtkwrite-exports-various-2d-3d-data-to-paraview-in-vtk-file-format.
I have the following matrices:
1) CRD(# of nodes, 2) which gives the 2D coordinates of the nodes,
2) Nodes(# of nodes per element,# of elements) which provides the connectivity between the nodes,
3) U(# of nodes, 2) which gives the x & y velocities per node, and
4) P(# of nodes, 1) which gives the pressure on a node.
However, I am not quite sure how can I put all these in the appropriate form so that they are compatible with the code. I went through several trials but it seems that the data are not saved properly. I would appreciate your help! Hello everyone!
I have 2D finite element data that are generated in matlab and I am trying to use this code for post-processing in Paraview:
https://www.mathworks.com/matlabcentral/fileexchange/47814-vtkwrite-exports-various-2d-3d-data-to-paraview-in-vtk-file-format.
I have the following matrices:
1) CRD(# of nodes, 2) which gives the 2D coordinates of the nodes,
2) Nodes(# of nodes per element,# of elements) which provides the connectivity between the nodes,
3) U(# of nodes, 2) which gives the x & y velocities per node, and
4) P(# of nodes, 1) which gives the pressure on a node.
However, I am not quite sure how can I put all these in the appropriate form so that they are compatible with the code. I went through several trials but it seems that the data are not saved properly. I would appreciate your help! paraview, finite element data MATLAB Answers — New Questions
setting an outputport to the function call type in an s function
Hello community.
I am working on a UDP receive block that is used with generated code for an embedded linux platform.
My goal is to have it output the message, message length and a function call output to process the message.
The block setup is currently like this
function sfcn_UDPReceive(block) %setup
tsamp = 1;
buff_len = 2;
%% Register number of input and output ports
block.NumInputPorts = 0;
block.NumOutputPorts = 2;
%% function call
%block.OutputPort(1); %Somehow set this to a function call? C code
%seems to suggest DatatypeID 9 is a function call, but it gives me an
%error when I use it here.
%% message length
block.OutputPort(2).Dimensions = 1;
block.OutputPort(2).DatatypeID = 7; %uint32
block.OutputPort(2).Complexity = ‘Real’;
block.OutputPort(2).SamplingMode = ‘sample’;
%% message
block.OutputPort(3).Dimensions = block.DialogPrm(buff_len).Data;
block.OutputPort(3).DatatypeID = 3; %uint8
block.OutputPort(3).Complexity = ‘Real’;
block.OutputPort(3).SamplingMode = ‘sample’;
% Number of S-Function parameters expected
% (tsamp, buff_len)
block.NumDialogPrms = 2;
block.SampleTimes = [block.DialogPrm(tsamp).Data 0];
block.RegBlockMethod(‘WriteRTW’, @WriteRTW);
end
function WriteRTW(block)
buff_len = 2; % make buff_len available to .tlc file
block.WriteRTWParam(‘string’, ‘buff_len’, num2str(block.DialogPrm(buff_len).Data));
end
How do I set block.OutputPort(1).DatatypeID to fcncall?
I have found examples of how to do it in C, which would then have to be compiled to mex files, but I like this interface being in regular matlab script.
The documentation for doing things this way seems way more scarse than that for the C-mex interface.Hello community.
I am working on a UDP receive block that is used with generated code for an embedded linux platform.
My goal is to have it output the message, message length and a function call output to process the message.
The block setup is currently like this
function sfcn_UDPReceive(block) %setup
tsamp = 1;
buff_len = 2;
%% Register number of input and output ports
block.NumInputPorts = 0;
block.NumOutputPorts = 2;
%% function call
%block.OutputPort(1); %Somehow set this to a function call? C code
%seems to suggest DatatypeID 9 is a function call, but it gives me an
%error when I use it here.
%% message length
block.OutputPort(2).Dimensions = 1;
block.OutputPort(2).DatatypeID = 7; %uint32
block.OutputPort(2).Complexity = ‘Real’;
block.OutputPort(2).SamplingMode = ‘sample’;
%% message
block.OutputPort(3).Dimensions = block.DialogPrm(buff_len).Data;
block.OutputPort(3).DatatypeID = 3; %uint8
block.OutputPort(3).Complexity = ‘Real’;
block.OutputPort(3).SamplingMode = ‘sample’;
% Number of S-Function parameters expected
% (tsamp, buff_len)
block.NumDialogPrms = 2;
block.SampleTimes = [block.DialogPrm(tsamp).Data 0];
block.RegBlockMethod(‘WriteRTW’, @WriteRTW);
end
function WriteRTW(block)
buff_len = 2; % make buff_len available to .tlc file
block.WriteRTWParam(‘string’, ‘buff_len’, num2str(block.DialogPrm(buff_len).Data));
end
How do I set block.OutputPort(1).DatatypeID to fcncall?
I have found examples of how to do it in C, which would then have to be compiled to mex files, but I like this interface being in regular matlab script.
The documentation for doing things this way seems way more scarse than that for the C-mex interface. Hello community.
I am working on a UDP receive block that is used with generated code for an embedded linux platform.
My goal is to have it output the message, message length and a function call output to process the message.
The block setup is currently like this
function sfcn_UDPReceive(block) %setup
tsamp = 1;
buff_len = 2;
%% Register number of input and output ports
block.NumInputPorts = 0;
block.NumOutputPorts = 2;
%% function call
%block.OutputPort(1); %Somehow set this to a function call? C code
%seems to suggest DatatypeID 9 is a function call, but it gives me an
%error when I use it here.
%% message length
block.OutputPort(2).Dimensions = 1;
block.OutputPort(2).DatatypeID = 7; %uint32
block.OutputPort(2).Complexity = ‘Real’;
block.OutputPort(2).SamplingMode = ‘sample’;
%% message
block.OutputPort(3).Dimensions = block.DialogPrm(buff_len).Data;
block.OutputPort(3).DatatypeID = 3; %uint8
block.OutputPort(3).Complexity = ‘Real’;
block.OutputPort(3).SamplingMode = ‘sample’;
% Number of S-Function parameters expected
% (tsamp, buff_len)
block.NumDialogPrms = 2;
block.SampleTimes = [block.DialogPrm(tsamp).Data 0];
block.RegBlockMethod(‘WriteRTW’, @WriteRTW);
end
function WriteRTW(block)
buff_len = 2; % make buff_len available to .tlc file
block.WriteRTWParam(‘string’, ‘buff_len’, num2str(block.DialogPrm(buff_len).Data));
end
How do I set block.OutputPort(1).DatatypeID to fcncall?
I have found examples of how to do it in C, which would then have to be compiled to mex files, but I like this interface being in regular matlab script.
The documentation for doing things this way seems way more scarse than that for the C-mex interface. level 2 s-function, simulink MATLAB Answers — New Questions
How to import hmdb51 dataset into MATLAB Online (For Classify Video Using Deep Learning MATLAB Tutorial)
Link: https://au.mathworks.com/help/deeplearning/ug/classify-videos-using-deep-learning.html
I am following the steps, but it seems like there are no steps to import the downloaded dataset into MATLAB Online, plus the file is too large. Thank youLink: https://au.mathworks.com/help/deeplearning/ug/classify-videos-using-deep-learning.html
I am following the steps, but it seems like there are no steps to import the downloaded dataset into MATLAB Online, plus the file is too large. Thank you Link: https://au.mathworks.com/help/deeplearning/ug/classify-videos-using-deep-learning.html
I am following the steps, but it seems like there are no steps to import the downloaded dataset into MATLAB Online, plus the file is too large. Thank you deep learning, video processing MATLAB Answers — New Questions
How to do LSM in 2 dimensional NULA
In 1D NULA, LSM could only be implemented as / indication. But in 2D NULA, why does this / not work? Then, how should LSM be done?In 1D NULA, LSM could only be implemented as / indication. But in 2D NULA, why does this / not work? Then, how should LSM be done? In 1D NULA, LSM could only be implemented as / indication. But in 2D NULA, why does this / not work? Then, how should LSM be done? lesat square method, 2d nula MATLAB Answers — New Questions
I am wondering if deep learning training is supported for code generation. I can see how to generate code for using a NNET, but not for the actual training of the NNET.
I used the original Neural Network Toolbox extensively. However, the code generation did not work for training the neural network, only the code for using a trained network.
Now we have Deep Learning Toolbox. Has that issue been solved?I used the original Neural Network Toolbox extensively. However, the code generation did not work for training the neural network, only the code for using a trained network.
Now we have Deep Learning Toolbox. Has that issue been solved? I used the original Neural Network Toolbox extensively. However, the code generation did not work for training the neural network, only the code for using a trained network.
Now we have Deep Learning Toolbox. Has that issue been solved? code generation, deep learning, deep learning hdl MATLAB Answers — New Questions
issues in creating a mex file that uses as c++ object that works on complex data type…
Hi,
I am trying to create a mex file that uses a c++ object called my_chain. The c++ function process() uses inputs that are of complex<int32_t> data type.
So, I used mxComplexInt32 to declare my arrays. Though the mex file gets compiled, Matlab crashes when I try to run the mex routine.
Any help in this regard is appreciated.
Regards
surendra
PS: Please find attached my mex file..
#include <iostream>
#include <complex>
#include "stdlib.h"
#include "mex.h"
#include "my_chain.h"
using namespace std;
/* The gateway function */
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray* prhs[])
{
complex<int> *input_data, *output_data;
int num_input_samples=0, num_output_samples=0, num_rows_out;
int bw_MHz; // Operating bandwidth
double f_rf_MHz; // RF frequency
double rs_ratio;
// Check for proper number of arguments
if (nrhs != 4) {
mexErrMsgIdAndTxt("MATLAB:mexcpp:nargin", "mexfn_rx_ds_chain requires four input arguments.");
}
if (nlhs != 1) {
mexErrMsgIdAndTxt("MATLAB:mexcpp:nargout", "mexfn_rx_ds_chain requires two outputs argument.");
}
f_rf_MHz = mxGetScalar(prhs[0]);
bw_MHz = mxGetScalar(prhs[1]);
input_data = (complex<int> *)mxGetComplexInt32s(prhs[2]);
num_input_samples = mxGetScalar(prhs[3]);
rs_ratio = f_rf_MHz/bw_MHz;
num_rows_out = (int)((double)num_input_samples/(32.0 * rs_ratio)) + 2;
plhs[0] = mxCreateNumericMatrix(num_rows_out,1,mxINT32_CLASS, mxCOMPLEX);
output_data = (complex<int> *)mxGetComplexInt32s(plhs[0]);
// instantiate object
my_chain object1(f_rf_MHz,bw_MHz);
mexPrintf("f_rf_MHz is %fn",f_rf_MHz);
mexPrintf("num_input_samples is %dn",num_input_samples);
//Matlab crashes if I the below lines are executed.
for(int ii=0; ii<20; ii++)
{
mexPrintf("%d %dn",input_data[ii].real(), input_data[ii].imag());
}
num_output_samples = object1.process(input_data, num_input_samples, output_data);
return;
}Hi,
I am trying to create a mex file that uses a c++ object called my_chain. The c++ function process() uses inputs that are of complex<int32_t> data type.
So, I used mxComplexInt32 to declare my arrays. Though the mex file gets compiled, Matlab crashes when I try to run the mex routine.
Any help in this regard is appreciated.
Regards
surendra
PS: Please find attached my mex file..
#include <iostream>
#include <complex>
#include "stdlib.h"
#include "mex.h"
#include "my_chain.h"
using namespace std;
/* The gateway function */
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray* prhs[])
{
complex<int> *input_data, *output_data;
int num_input_samples=0, num_output_samples=0, num_rows_out;
int bw_MHz; // Operating bandwidth
double f_rf_MHz; // RF frequency
double rs_ratio;
// Check for proper number of arguments
if (nrhs != 4) {
mexErrMsgIdAndTxt("MATLAB:mexcpp:nargin", "mexfn_rx_ds_chain requires four input arguments.");
}
if (nlhs != 1) {
mexErrMsgIdAndTxt("MATLAB:mexcpp:nargout", "mexfn_rx_ds_chain requires two outputs argument.");
}
f_rf_MHz = mxGetScalar(prhs[0]);
bw_MHz = mxGetScalar(prhs[1]);
input_data = (complex<int> *)mxGetComplexInt32s(prhs[2]);
num_input_samples = mxGetScalar(prhs[3]);
rs_ratio = f_rf_MHz/bw_MHz;
num_rows_out = (int)((double)num_input_samples/(32.0 * rs_ratio)) + 2;
plhs[0] = mxCreateNumericMatrix(num_rows_out,1,mxINT32_CLASS, mxCOMPLEX);
output_data = (complex<int> *)mxGetComplexInt32s(plhs[0]);
// instantiate object
my_chain object1(f_rf_MHz,bw_MHz);
mexPrintf("f_rf_MHz is %fn",f_rf_MHz);
mexPrintf("num_input_samples is %dn",num_input_samples);
//Matlab crashes if I the below lines are executed.
for(int ii=0; ii<20; ii++)
{
mexPrintf("%d %dn",input_data[ii].real(), input_data[ii].imag());
}
num_output_samples = object1.process(input_data, num_input_samples, output_data);
return;
} Hi,
I am trying to create a mex file that uses a c++ object called my_chain. The c++ function process() uses inputs that are of complex<int32_t> data type.
So, I used mxComplexInt32 to declare my arrays. Though the mex file gets compiled, Matlab crashes when I try to run the mex routine.
Any help in this regard is appreciated.
Regards
surendra
PS: Please find attached my mex file..
#include <iostream>
#include <complex>
#include "stdlib.h"
#include "mex.h"
#include "my_chain.h"
using namespace std;
/* The gateway function */
void mexFunction(int nlhs, mxArray *plhs[],
int nrhs, const mxArray* prhs[])
{
complex<int> *input_data, *output_data;
int num_input_samples=0, num_output_samples=0, num_rows_out;
int bw_MHz; // Operating bandwidth
double f_rf_MHz; // RF frequency
double rs_ratio;
// Check for proper number of arguments
if (nrhs != 4) {
mexErrMsgIdAndTxt("MATLAB:mexcpp:nargin", "mexfn_rx_ds_chain requires four input arguments.");
}
if (nlhs != 1) {
mexErrMsgIdAndTxt("MATLAB:mexcpp:nargout", "mexfn_rx_ds_chain requires two outputs argument.");
}
f_rf_MHz = mxGetScalar(prhs[0]);
bw_MHz = mxGetScalar(prhs[1]);
input_data = (complex<int> *)mxGetComplexInt32s(prhs[2]);
num_input_samples = mxGetScalar(prhs[3]);
rs_ratio = f_rf_MHz/bw_MHz;
num_rows_out = (int)((double)num_input_samples/(32.0 * rs_ratio)) + 2;
plhs[0] = mxCreateNumericMatrix(num_rows_out,1,mxINT32_CLASS, mxCOMPLEX);
output_data = (complex<int> *)mxGetComplexInt32s(plhs[0]);
// instantiate object
my_chain object1(f_rf_MHz,bw_MHz);
mexPrintf("f_rf_MHz is %fn",f_rf_MHz);
mexPrintf("num_input_samples is %dn",num_input_samples);
//Matlab crashes if I the below lines are executed.
for(int ii=0; ii<20; ii++)
{
mexPrintf("%d %dn",input_data[ii].real(), input_data[ii].imag());
}
num_output_samples = object1.process(input_data, num_input_samples, output_data);
return;
} complex data types in mex files MATLAB Answers — New Questions
How to improve computing speed of mincx
Hi, I would like to ask you how to improve computing speed of mincx in linear matrix inequality.
As the number of variables increases, it takes longer to solve the linear matrix inequalities with mincx.
So, how can I improve the computing speed?
Or, do you have any ideas on how to use GPU for computing the solution of linear matrix inequality?Hi, I would like to ask you how to improve computing speed of mincx in linear matrix inequality.
As the number of variables increases, it takes longer to solve the linear matrix inequalities with mincx.
So, how can I improve the computing speed?
Or, do you have any ideas on how to use GPU for computing the solution of linear matrix inequality? Hi, I would like to ask you how to improve computing speed of mincx in linear matrix inequality.
As the number of variables increases, it takes longer to solve the linear matrix inequalities with mincx.
So, how can I improve the computing speed?
Or, do you have any ideas on how to use GPU for computing the solution of linear matrix inequality? mincx, lmi, linear matrix inequality MATLAB Answers — New Questions