Category: Matlab
Category Archives: Matlab
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
How to create union in simulink
Hellow.
I have a question about how to union in simulink in simulink coder.
I know how to create the bus of struct using the ‘Simulink bus’ in dictionary file. (*.sldd)
However, i can’t see the part that creates the union.
Does Mathoworks support the method of generating code an union as shown below?
If so, could you tell me how?
thank you
**************************************************************************************
typedef union
{
uint32 R;
uint16 H;
} Test_u;
**************************************************************************************Hellow.
I have a question about how to union in simulink in simulink coder.
I know how to create the bus of struct using the ‘Simulink bus’ in dictionary file. (*.sldd)
However, i can’t see the part that creates the union.
Does Mathoworks support the method of generating code an union as shown below?
If so, could you tell me how?
thank you
**************************************************************************************
typedef union
{
uint32 R;
uint16 H;
} Test_u;
************************************************************************************** Hellow.
I have a question about how to union in simulink in simulink coder.
I know how to create the bus of struct using the ‘Simulink bus’ in dictionary file. (*.sldd)
However, i can’t see the part that creates the union.
Does Mathoworks support the method of generating code an union as shown below?
If so, could you tell me how?
thank you
**************************************************************************************
typedef union
{
uint32 R;
uint16 H;
} Test_u;
************************************************************************************** simulink, code generation, union MATLAB Answers — New Questions
How to fix the size of markers when drawing in Matlab? Make the marker larger with local magnification instead of being fixed and unchanged.
I want to use the markers in the picture to represent the drones in the formation. When the canvas shrinks, the size of the markers should decrease accordingly, and when the area is zoomed in, the markers should increase accordingly. But the actual situation is exactly the opposite.
For example, for the following programs, the markers in the left image should be smaller, and the markers in the right image should be larger.
Can you help me? Thank you very much.
%%%
x = [10 20 30 40];
y = [20 10 10 20];
plot(x,y,’g’, ‘linewidth’, 2)
text(x, y, ‘✤’, ‘color’, ‘r’, ‘fontsize’, 20, ‘HorizontalAlignment’, ‘center’, ‘VerticalAlignment’, ‘middle’);I want to use the markers in the picture to represent the drones in the formation. When the canvas shrinks, the size of the markers should decrease accordingly, and when the area is zoomed in, the markers should increase accordingly. But the actual situation is exactly the opposite.
For example, for the following programs, the markers in the left image should be smaller, and the markers in the right image should be larger.
Can you help me? Thank you very much.
%%%
x = [10 20 30 40];
y = [20 10 10 20];
plot(x,y,’g’, ‘linewidth’, 2)
text(x, y, ‘✤’, ‘color’, ‘r’, ‘fontsize’, 20, ‘HorizontalAlignment’, ‘center’, ‘VerticalAlignment’, ‘middle’); I want to use the markers in the picture to represent the drones in the formation. When the canvas shrinks, the size of the markers should decrease accordingly, and when the area is zoomed in, the markers should increase accordingly. But the actual situation is exactly the opposite.
For example, for the following programs, the markers in the left image should be smaller, and the markers in the right image should be larger.
Can you help me? Thank you very much.
%%%
x = [10 20 30 40];
y = [20 10 10 20];
plot(x,y,’g’, ‘linewidth’, 2)
text(x, y, ‘✤’, ‘color’, ‘r’, ‘fontsize’, 20, ‘HorizontalAlignment’, ‘center’, ‘VerticalAlignment’, ‘middle’); plotting, plot, text MATLAB Answers — New Questions
“feedback” function example in Matlab documentation doesn’t seem to work?
I am trying to reproduce Example 2 in the documentation for the function "feedback" in Matlab2014a.
*The example* :
Consider a state-space plant P with five inputs and four outputs and a state-space feedback controller K with three inputs and two outputs. To connect outputs 1, 3, and 4 of the plant to the controller inputs, and the controller outputs to inputs 4 and 2 of the plant, use
feedin = [4 2];
feedout = [1 3 4];
Cloop = feedback(P,K,feedin,feedout)
*My code* :
P = rss(4,4,5);
K = rss(2,2,3);
feedin = [4 2];
feedout = [1 3 4];
Cloop = feedback(P,K,feedin,feedout);
size(Cloop)
*Result*:
Instead of returning a 3 input, 1 output closed-loop system, Matlab gives a system of the same size as P:
State-space model with 4 outputs, 5 inputs, and 6 states.
Why isn’t this working properly?I am trying to reproduce Example 2 in the documentation for the function "feedback" in Matlab2014a.
*The example* :
Consider a state-space plant P with five inputs and four outputs and a state-space feedback controller K with three inputs and two outputs. To connect outputs 1, 3, and 4 of the plant to the controller inputs, and the controller outputs to inputs 4 and 2 of the plant, use
feedin = [4 2];
feedout = [1 3 4];
Cloop = feedback(P,K,feedin,feedout)
*My code* :
P = rss(4,4,5);
K = rss(2,2,3);
feedin = [4 2];
feedout = [1 3 4];
Cloop = feedback(P,K,feedin,feedout);
size(Cloop)
*Result*:
Instead of returning a 3 input, 1 output closed-loop system, Matlab gives a system of the same size as P:
State-space model with 4 outputs, 5 inputs, and 6 states.
Why isn’t this working properly? I am trying to reproduce Example 2 in the documentation for the function "feedback" in Matlab2014a.
*The example* :
Consider a state-space plant P with five inputs and four outputs and a state-space feedback controller K with three inputs and two outputs. To connect outputs 1, 3, and 4 of the plant to the controller inputs, and the controller outputs to inputs 4 and 2 of the plant, use
feedin = [4 2];
feedout = [1 3 4];
Cloop = feedback(P,K,feedin,feedout)
*My code* :
P = rss(4,4,5);
K = rss(2,2,3);
feedin = [4 2];
feedout = [1 3 4];
Cloop = feedback(P,K,feedin,feedout);
size(Cloop)
*Result*:
Instead of returning a 3 input, 1 output closed-loop system, Matlab gives a system of the same size as P:
State-space model with 4 outputs, 5 inputs, and 6 states.
Why isn’t this working properly? feedback, closed loop MATLAB Answers — New Questions
DWARF Parser internal error: Parser::describeSymbol xcpDummyDoubleVariable is not a global variable.
The project is loaded from "Embedded Coder Support Package for STMicroelectronics Discovery Boards".
If pressing "run" or "Build,Deploy & Start",there is no error returned.pressing the "Monitor & turn" button will return errors.
The errors returned are shown below:
External Mode Open Protocol Connect command failed
Caused by:
DWARF Parser internal error: Parser::describeSymbol xcpDummyDoubleVariable is not a global variable
Component:Simulink | Category:Block diagram error
Unable to connect to the ‘STM32F746G-Discovery’ target for ‘stm32f746gdiscovery_audio_equalizer’.
Component:Simulink | Category:Model error
If other modules are commented out and only input and output are left, as shown in the figure, this error message will still be reported. This problem will not appear on the stm32f4 disco development board. Note that stm32f4 uses an additional ttl-233.The project is loaded from "Embedded Coder Support Package for STMicroelectronics Discovery Boards".
If pressing "run" or "Build,Deploy & Start",there is no error returned.pressing the "Monitor & turn" button will return errors.
The errors returned are shown below:
External Mode Open Protocol Connect command failed
Caused by:
DWARF Parser internal error: Parser::describeSymbol xcpDummyDoubleVariable is not a global variable
Component:Simulink | Category:Block diagram error
Unable to connect to the ‘STM32F746G-Discovery’ target for ‘stm32f746gdiscovery_audio_equalizer’.
Component:Simulink | Category:Model error
If other modules are commented out and only input and output are left, as shown in the figure, this error message will still be reported. This problem will not appear on the stm32f4 disco development board. Note that stm32f4 uses an additional ttl-233. The project is loaded from "Embedded Coder Support Package for STMicroelectronics Discovery Boards".
If pressing "run" or "Build,Deploy & Start",there is no error returned.pressing the "Monitor & turn" button will return errors.
The errors returned are shown below:
External Mode Open Protocol Connect command failed
Caused by:
DWARF Parser internal error: Parser::describeSymbol xcpDummyDoubleVariable is not a global variable
Component:Simulink | Category:Block diagram error
Unable to connect to the ‘STM32F746G-Discovery’ target for ‘stm32f746gdiscovery_audio_equalizer’.
Component:Simulink | Category:Model error
If other modules are commented out and only input and output are left, as shown in the figure, this error message will still be reported. This problem will not appear on the stm32f4 disco development board. Note that stm32f4 uses an additional ttl-233. stm32f746g discovery board, stm, simulink, external mode, monitor and turn MATLAB Answers — New Questions
spectrum(x, log=”no”,span=5, plot=FALSE) similar command in Matlab.
My Matlab code is like following:
del = 1/120; % lenght of sampling interval
subplot(3,1,1)
I= pop(:,2);
I1= I(4801:end)/10000;
plot(t(4801:end),I1,LineWidth=1.5);
xlabel ‘Time’;
ylabel ‘Infectious population, I’;
subplot(3,1,2)
S = abs(fft(I1));
L = length(S);
S_oneside= S(1:L/2);
f = (1/del)*(0:L/2-1)/L; %frequency question
S_meg=abs(S_oneside)/(L/2);
P=findpeaks(S_meg);
plot(f,S_meg,LineWidth=1.5);
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
subplot(3,1,3)
plot(f,S_meg,LineWidth=1.5)
xlim([0.1 2])
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
This gives me the correct graph. But in R for smoothing they use span = 5, how can I smooth the peaks in Matlab?My Matlab code is like following:
del = 1/120; % lenght of sampling interval
subplot(3,1,1)
I= pop(:,2);
I1= I(4801:end)/10000;
plot(t(4801:end),I1,LineWidth=1.5);
xlabel ‘Time’;
ylabel ‘Infectious population, I’;
subplot(3,1,2)
S = abs(fft(I1));
L = length(S);
S_oneside= S(1:L/2);
f = (1/del)*(0:L/2-1)/L; %frequency question
S_meg=abs(S_oneside)/(L/2);
P=findpeaks(S_meg);
plot(f,S_meg,LineWidth=1.5);
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
subplot(3,1,3)
plot(f,S_meg,LineWidth=1.5)
xlim([0.1 2])
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
This gives me the correct graph. But in R for smoothing they use span = 5, how can I smooth the peaks in Matlab? My Matlab code is like following:
del = 1/120; % lenght of sampling interval
subplot(3,1,1)
I= pop(:,2);
I1= I(4801:end)/10000;
plot(t(4801:end),I1,LineWidth=1.5);
xlabel ‘Time’;
ylabel ‘Infectious population, I’;
subplot(3,1,2)
S = abs(fft(I1));
L = length(S);
S_oneside= S(1:L/2);
f = (1/del)*(0:L/2-1)/L; %frequency question
S_meg=abs(S_oneside)/(L/2);
P=findpeaks(S_meg);
plot(f,S_meg,LineWidth=1.5);
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
subplot(3,1,3)
plot(f,S_meg,LineWidth=1.5)
xlim([0.1 2])
xlabel ‘Frequency’;
ylabel ‘Spectral density’;
This gives me the correct graph. But in R for smoothing they use span = 5, how can I smooth the peaks in Matlab? spectrum analysis MATLAB Answers — New Questions
Help, I need to know how to build a dataset. I have 7 txt file of bearing raw vibration generated. If can I need step by step. Already three days search.
Here attached with all raw vibration data mentioned above.Here attached with all raw vibration data mentioned above. Here attached with all raw vibration data mentioned above. dataset, data MATLAB Answers — New Questions