Category: Matlab
Category Archives: Matlab
Baeglebone Black in Simulink can’t handle sample time of 0.001s.
Beeaglebone black with simulink can’t handle 1kHz. I am trying with just a Led blinking example. When I put 0.001s of sample time in the model configuration panel and StopTime simulation of 10s. Looks like the BBB is taking longer than 10s to finish the code. I am also deploying the code to the hardware, not seeing any signal in "real time".Beeaglebone black with simulink can’t handle 1kHz. I am trying with just a Led blinking example. When I put 0.001s of sample time in the model configuration panel and StopTime simulation of 10s. Looks like the BBB is taking longer than 10s to finish the code. I am also deploying the code to the hardware, not seeing any signal in "real time". Beeaglebone black with simulink can’t handle 1kHz. I am trying with just a Led blinking example. When I put 0.001s of sample time in the model configuration panel and StopTime simulation of 10s. Looks like the BBB is taking longer than 10s to finish the code. I am also deploying the code to the hardware, not seeing any signal in "real time". beaglebone black, simulink MATLAB Answers — New Questions
Narx network in real-time task
Good afternoon,
I understand that the topic of NARX networks has been discussed here for over 10 years, but I would like to revisit it.
I attempted to implement a solution for processing data from a sensor in real-time, but unfortunately, I could not find any examples demonstrating how to do this correctly. Most publications on this topic either conclude with a performance evaluation of the network or focus on discussions of the code generated by the application.
Let me share some code:
% targer timeseries
T = num2cell(lfarr(1:8000));
% input timeseries from sensor
X = num2cell(source(1:8000));
The signals are extremely simple – data from the sensor and its smoothed version.
Next, I followed the standard steps outlined in the documentation and various discussions on this forum:
%create narxnet
sh = 7
d1 = [1:sh];
d2 = [1:sh];
narx_net = narxnet(d1,d2,20);
narx_netnet.divideFcn = ‘divideblock’;
(If Greg suddenly comes, tell him that I remember about autocorrelation and am already carefully studying his code from user group :))
% standard data preparation
[Xs,Xi,Ai,Ts] = preparets(narx_net,X,{},T);
% training
rng( ‘default’ )
[narx_net, tr, Ys, Es, Xf, Af ] = train(narx_net,Xs,Ts,Xi,Ai);
% performance evaluation
[Y,Xf,Af] = narx_net(Xs,Xi,Ai);
perf = perform(narx_net,Ts,Y) % perf = 3.4381e-08. I think it’s not bad.
The regression diagram speaks for itself
Next I close the network and simulate signal processing on the remainder of the data that the network has not seen.
Here, I tried to base my approach on the last two paragraphs of the documentation – Following Closed-Loop Simulation with Open-Loop Simulation.
[narx_netc,Xic,Aic] = closeloop(narx_net, Xf, Af);
% number of prediction steps
k = 5;
% A loop that simulates a real-time data flow
for i = 8001:length(lf_arr)
% getting a new value from the sensor
newSensorValue = num2cell(source(i));
% local variable for indexing the prediction array
ii = 1;
% array of predictions
res = [];
% predictions for k steps
for j=i:i+k
[Yc, Xic, Aic] = narx_netc(newSensorValue, Xic, Aic);
% disp([‘Predicted meaning: ‘, num2str(cell2mat(Yc))]);
res(ii) = cell2mat(Yc);
ii = ii+1;
end
% saving results
res1(i-8000,:) = res’;
% form new input and target arrays with new input value and the predicted result
u = [X(2:end),newSensorValue];
y = [T(2:end), {res(1)}];
% repeating initialization cycle for next simulation step
[X1,Xi,Ai,T1] = preparets(narx_net,u,{},y);
[Y,Xio,Aio] = narx_net(X1,Xi,Ai);
[narx_netc,Xic,Aic] = closeloop(narx_net, Xio, Aio);
end
The network starts working, but after some steps its normal operation stops.
I would be immensely grateful for any insights into where my reasoning or actions might have gone astray.
ThanksGood afternoon,
I understand that the topic of NARX networks has been discussed here for over 10 years, but I would like to revisit it.
I attempted to implement a solution for processing data from a sensor in real-time, but unfortunately, I could not find any examples demonstrating how to do this correctly. Most publications on this topic either conclude with a performance evaluation of the network or focus on discussions of the code generated by the application.
Let me share some code:
% targer timeseries
T = num2cell(lfarr(1:8000));
% input timeseries from sensor
X = num2cell(source(1:8000));
The signals are extremely simple – data from the sensor and its smoothed version.
Next, I followed the standard steps outlined in the documentation and various discussions on this forum:
%create narxnet
sh = 7
d1 = [1:sh];
d2 = [1:sh];
narx_net = narxnet(d1,d2,20);
narx_netnet.divideFcn = ‘divideblock’;
(If Greg suddenly comes, tell him that I remember about autocorrelation and am already carefully studying his code from user group :))
% standard data preparation
[Xs,Xi,Ai,Ts] = preparets(narx_net,X,{},T);
% training
rng( ‘default’ )
[narx_net, tr, Ys, Es, Xf, Af ] = train(narx_net,Xs,Ts,Xi,Ai);
% performance evaluation
[Y,Xf,Af] = narx_net(Xs,Xi,Ai);
perf = perform(narx_net,Ts,Y) % perf = 3.4381e-08. I think it’s not bad.
The regression diagram speaks for itself
Next I close the network and simulate signal processing on the remainder of the data that the network has not seen.
Here, I tried to base my approach on the last two paragraphs of the documentation – Following Closed-Loop Simulation with Open-Loop Simulation.
[narx_netc,Xic,Aic] = closeloop(narx_net, Xf, Af);
% number of prediction steps
k = 5;
% A loop that simulates a real-time data flow
for i = 8001:length(lf_arr)
% getting a new value from the sensor
newSensorValue = num2cell(source(i));
% local variable for indexing the prediction array
ii = 1;
% array of predictions
res = [];
% predictions for k steps
for j=i:i+k
[Yc, Xic, Aic] = narx_netc(newSensorValue, Xic, Aic);
% disp([‘Predicted meaning: ‘, num2str(cell2mat(Yc))]);
res(ii) = cell2mat(Yc);
ii = ii+1;
end
% saving results
res1(i-8000,:) = res’;
% form new input and target arrays with new input value and the predicted result
u = [X(2:end),newSensorValue];
y = [T(2:end), {res(1)}];
% repeating initialization cycle for next simulation step
[X1,Xi,Ai,T1] = preparets(narx_net,u,{},y);
[Y,Xio,Aio] = narx_net(X1,Xi,Ai);
[narx_netc,Xic,Aic] = closeloop(narx_net, Xio, Aio);
end
The network starts working, but after some steps its normal operation stops.
I would be immensely grateful for any insights into where my reasoning or actions might have gone astray.
Thanks Good afternoon,
I understand that the topic of NARX networks has been discussed here for over 10 years, but I would like to revisit it.
I attempted to implement a solution for processing data from a sensor in real-time, but unfortunately, I could not find any examples demonstrating how to do this correctly. Most publications on this topic either conclude with a performance evaluation of the network or focus on discussions of the code generated by the application.
Let me share some code:
% targer timeseries
T = num2cell(lfarr(1:8000));
% input timeseries from sensor
X = num2cell(source(1:8000));
The signals are extremely simple – data from the sensor and its smoothed version.
Next, I followed the standard steps outlined in the documentation and various discussions on this forum:
%create narxnet
sh = 7
d1 = [1:sh];
d2 = [1:sh];
narx_net = narxnet(d1,d2,20);
narx_netnet.divideFcn = ‘divideblock’;
(If Greg suddenly comes, tell him that I remember about autocorrelation and am already carefully studying his code from user group :))
% standard data preparation
[Xs,Xi,Ai,Ts] = preparets(narx_net,X,{},T);
% training
rng( ‘default’ )
[narx_net, tr, Ys, Es, Xf, Af ] = train(narx_net,Xs,Ts,Xi,Ai);
% performance evaluation
[Y,Xf,Af] = narx_net(Xs,Xi,Ai);
perf = perform(narx_net,Ts,Y) % perf = 3.4381e-08. I think it’s not bad.
The regression diagram speaks for itself
Next I close the network and simulate signal processing on the remainder of the data that the network has not seen.
Here, I tried to base my approach on the last two paragraphs of the documentation – Following Closed-Loop Simulation with Open-Loop Simulation.
[narx_netc,Xic,Aic] = closeloop(narx_net, Xf, Af);
% number of prediction steps
k = 5;
% A loop that simulates a real-time data flow
for i = 8001:length(lf_arr)
% getting a new value from the sensor
newSensorValue = num2cell(source(i));
% local variable for indexing the prediction array
ii = 1;
% array of predictions
res = [];
% predictions for k steps
for j=i:i+k
[Yc, Xic, Aic] = narx_netc(newSensorValue, Xic, Aic);
% disp([‘Predicted meaning: ‘, num2str(cell2mat(Yc))]);
res(ii) = cell2mat(Yc);
ii = ii+1;
end
% saving results
res1(i-8000,:) = res’;
% form new input and target arrays with new input value and the predicted result
u = [X(2:end),newSensorValue];
y = [T(2:end), {res(1)}];
% repeating initialization cycle for next simulation step
[X1,Xi,Ai,T1] = preparets(narx_net,u,{},y);
[Y,Xio,Aio] = narx_net(X1,Xi,Ai);
[narx_netc,Xic,Aic] = closeloop(narx_net, Xio, Aio);
end
The network starts working, but after some steps its normal operation stops.
I would be immensely grateful for any insights into where my reasoning or actions might have gone astray.
Thanks narx network MATLAB Answers — New Questions
How to resolve EDO System
Hi,
I need to know how to resolve EDO System with MATLAB. The system has this structure:
A*x̄’ + B*x̄ + C = 0
A, B are square matrix with constant coefficients. Example: A = [a b; c d]; and B = [e f; g h];
C is the constant vector transposed. Example: C = [i j]’;
x̄ is the vector transposed of the variables/functions I need to find. Example: x̄ = [x1 x2]’;
x̄’ is the vector transposed of the derivative of the variables/functions I need to find. Example: x̄’ = [dx1/dt dx2/dt]’;
The example is made for a EDO System of 2 differential equations. But It would be interesting if MATLAB could resolve a n x n matrix.
Any suggestion?Hi,
I need to know how to resolve EDO System with MATLAB. The system has this structure:
A*x̄’ + B*x̄ + C = 0
A, B are square matrix with constant coefficients. Example: A = [a b; c d]; and B = [e f; g h];
C is the constant vector transposed. Example: C = [i j]’;
x̄ is the vector transposed of the variables/functions I need to find. Example: x̄ = [x1 x2]’;
x̄’ is the vector transposed of the derivative of the variables/functions I need to find. Example: x̄’ = [dx1/dt dx2/dt]’;
The example is made for a EDO System of 2 differential equations. But It would be interesting if MATLAB could resolve a n x n matrix.
Any suggestion? Hi,
I need to know how to resolve EDO System with MATLAB. The system has this structure:
A*x̄’ + B*x̄ + C = 0
A, B are square matrix with constant coefficients. Example: A = [a b; c d]; and B = [e f; g h];
C is the constant vector transposed. Example: C = [i j]’;
x̄ is the vector transposed of the variables/functions I need to find. Example: x̄ = [x1 x2]’;
x̄’ is the vector transposed of the derivative of the variables/functions I need to find. Example: x̄’ = [dx1/dt dx2/dt]’;
The example is made for a EDO System of 2 differential equations. But It would be interesting if MATLAB could resolve a n x n matrix.
Any suggestion? second order edo system MATLAB Answers — New Questions
Matlab creates netcdf file but can’t open it later(ERROR: The NetCDF library encountered an error during execution of ‘open’ function – ‘Unknown file format (NC_ENOTNC)’
Hello, I’ve encountered a problem with NetCDF library, I would be very grateful for any tips how to solve it.
I’m trying to create a netcdffile and write variables in it. But for some reason after creating a file I can’t reach it anyhow (nccreate, ncdisp are getting the same error):
ncid = netcdf.create(‘F:GLORYS_dayARCGLORYS_surf.nc’,’NETCDF4′);
nccreate(‘F:GLORYS_dayARCGLORYS_surf.nc’,’Lat’,’Dimensions’,{‘Lat’ 205});
Error using matlab.internal.imagesci.netcdflib
The NetCDF library encountered an error during execution of ‘open’ function – ‘Unknown file format (NC_ENOTNC)’.
Error in netcdf.open (line 77)
[varargout{:}] = matlab.internal.imagesci.netcdflib(‘open’, …
Error in internal.matlab.imagesci.nc/openToAppend (line 1250)
this.ncRootid = netcdf.open(this.Filename,’WRITE’);
Error in internal.matlab.imagesci.nc (line 126)
this.openToAppend();
Error in nccreate (line 159)
ncObj = internal.matlab.imagesci.nc(ncFile,’a’, formatStr);
Error in export_to_netcdf (line 10)
nccreate(‘F:GLORYS_dayARCGLORYS_surf.nc’,’Lat’,’Dimensions’,{‘Lat’ 205});Hello, I’ve encountered a problem with NetCDF library, I would be very grateful for any tips how to solve it.
I’m trying to create a netcdffile and write variables in it. But for some reason after creating a file I can’t reach it anyhow (nccreate, ncdisp are getting the same error):
ncid = netcdf.create(‘F:GLORYS_dayARCGLORYS_surf.nc’,’NETCDF4′);
nccreate(‘F:GLORYS_dayARCGLORYS_surf.nc’,’Lat’,’Dimensions’,{‘Lat’ 205});
Error using matlab.internal.imagesci.netcdflib
The NetCDF library encountered an error during execution of ‘open’ function – ‘Unknown file format (NC_ENOTNC)’.
Error in netcdf.open (line 77)
[varargout{:}] = matlab.internal.imagesci.netcdflib(‘open’, …
Error in internal.matlab.imagesci.nc/openToAppend (line 1250)
this.ncRootid = netcdf.open(this.Filename,’WRITE’);
Error in internal.matlab.imagesci.nc (line 126)
this.openToAppend();
Error in nccreate (line 159)
ncObj = internal.matlab.imagesci.nc(ncFile,’a’, formatStr);
Error in export_to_netcdf (line 10)
nccreate(‘F:GLORYS_dayARCGLORYS_surf.nc’,’Lat’,’Dimensions’,{‘Lat’ 205}); Hello, I’ve encountered a problem with NetCDF library, I would be very grateful for any tips how to solve it.
I’m trying to create a netcdffile and write variables in it. But for some reason after creating a file I can’t reach it anyhow (nccreate, ncdisp are getting the same error):
ncid = netcdf.create(‘F:GLORYS_dayARCGLORYS_surf.nc’,’NETCDF4′);
nccreate(‘F:GLORYS_dayARCGLORYS_surf.nc’,’Lat’,’Dimensions’,{‘Lat’ 205});
Error using matlab.internal.imagesci.netcdflib
The NetCDF library encountered an error during execution of ‘open’ function – ‘Unknown file format (NC_ENOTNC)’.
Error in netcdf.open (line 77)
[varargout{:}] = matlab.internal.imagesci.netcdflib(‘open’, …
Error in internal.matlab.imagesci.nc/openToAppend (line 1250)
this.ncRootid = netcdf.open(this.Filename,’WRITE’);
Error in internal.matlab.imagesci.nc (line 126)
this.openToAppend();
Error in nccreate (line 159)
ncObj = internal.matlab.imagesci.nc(ncFile,’a’, formatStr);
Error in export_to_netcdf (line 10)
nccreate(‘F:GLORYS_dayARCGLORYS_surf.nc’,’Lat’,’Dimensions’,{‘Lat’ 205}); netcdf MATLAB Answers — New Questions
Problem with Fuzzy controller blocks in simulink
I’ve already developed a control model by using fuzzy controller in simulink. there are some problems that seems like bugs. If you just agree with me please let me know how can I report this bugs to _Mathworks_ respondents?
1. When I use a fuzzy controller block with rule viewer, the block output is zero all the time however rule viewer works properly and show true outputs. When I try to show block output signal by using the tool _show value label of the port_ I see that the value is _grounded_ all the time.
2. The aforementioned problem does not exist for the fuzzy controller block without rule viewer. But there is another problem. The fuzzy controller works properly since a point time and after that reports zero in the rest of the simulation. I’m sure that this problem does not come from my fuzzy structure file and rule base because I’ve checked it outside simulink in programming environment. it works properly.
Thanks in advance
PouyaI’ve already developed a control model by using fuzzy controller in simulink. there are some problems that seems like bugs. If you just agree with me please let me know how can I report this bugs to _Mathworks_ respondents?
1. When I use a fuzzy controller block with rule viewer, the block output is zero all the time however rule viewer works properly and show true outputs. When I try to show block output signal by using the tool _show value label of the port_ I see that the value is _grounded_ all the time.
2. The aforementioned problem does not exist for the fuzzy controller block without rule viewer. But there is another problem. The fuzzy controller works properly since a point time and after that reports zero in the rest of the simulation. I’m sure that this problem does not come from my fuzzy structure file and rule base because I’ve checked it outside simulink in programming environment. it works properly.
Thanks in advance
Pouya I’ve already developed a control model by using fuzzy controller in simulink. there are some problems that seems like bugs. If you just agree with me please let me know how can I report this bugs to _Mathworks_ respondents?
1. When I use a fuzzy controller block with rule viewer, the block output is zero all the time however rule viewer works properly and show true outputs. When I try to show block output signal by using the tool _show value label of the port_ I see that the value is _grounded_ all the time.
2. The aforementioned problem does not exist for the fuzzy controller block without rule viewer. But there is another problem. The fuzzy controller works properly since a point time and after that reports zero in the rest of the simulation. I’m sure that this problem does not come from my fuzzy structure file and rule base because I’ve checked it outside simulink in programming environment. it works properly.
Thanks in advance
Pouya bug, fuzzy block with rule viewer, fuzzy control systems MATLAB Answers — New Questions
Make figure without white border
I have a piece of code that plots a surface, and I feel it is ready for being included into the report. The only thing is that the figure has a quite large white border which substantially increases the size of it. I would like to have the unnecessary white space reduced to a minimum.
I did try
set(gca,’LooseInset’,get(gca,’TightInset’))
But this cuts off my z-axis label. Is there an easy way to achieve this? With LaTeX, we can simply use the standalone documentclass with PGFplots/tikz, but I don’t think there’s a simple keyword or option to do this with matlab. I’m using R2016b.I have a piece of code that plots a surface, and I feel it is ready for being included into the report. The only thing is that the figure has a quite large white border which substantially increases the size of it. I would like to have the unnecessary white space reduced to a minimum.
I did try
set(gca,’LooseInset’,get(gca,’TightInset’))
But this cuts off my z-axis label. Is there an easy way to achieve this? With LaTeX, we can simply use the standalone documentclass with PGFplots/tikz, but I don’t think there’s a simple keyword or option to do this with matlab. I’m using R2016b. I have a piece of code that plots a surface, and I feel it is ready for being included into the report. The only thing is that the figure has a quite large white border which substantially increases the size of it. I would like to have the unnecessary white space reduced to a minimum.
I did try
set(gca,’LooseInset’,get(gca,’TightInset’))
But this cuts off my z-axis label. Is there an easy way to achieve this? With LaTeX, we can simply use the standalone documentclass with PGFplots/tikz, but I don’t think there’s a simple keyword or option to do this with matlab. I’m using R2016b. figure MATLAB Answers — New Questions
Why do I get a Microsoft Visual C++ Redistributable error 1935 when installing MATLAB on Windows?
I get the following error when installing MATLAB on Windows:
ERROR: Error 1935. An error occurred during the installation of assembly
‘Microsoft.VC80.ATL.type="win32",version="8.0.50727.762".publicKeyToken="1fc8b3b9a1e18e3b".processorArchitecture="amd64"’.
Please refer to Help and Support for more information.I get the following error when installing MATLAB on Windows:
ERROR: Error 1935. An error occurred during the installation of assembly
‘Microsoft.VC80.ATL.type="win32",version="8.0.50727.762".publicKeyToken="1fc8b3b9a1e18e3b".processorArchitecture="amd64"’.
Please refer to Help and Support for more information. I get the following error when installing MATLAB on Windows:
ERROR: Error 1935. An error occurred during the installation of assembly
‘Microsoft.VC80.ATL.type="win32",version="8.0.50727.762".publicKeyToken="1fc8b3b9a1e18e3b".processorArchitecture="amd64"’.
Please refer to Help and Support for more information. msvc, compiler MATLAB Answers — New Questions
Does MATLAB support quadruple precision – 128-bit floating point arithmetics?
I need more precision than offered by the standard double data type in MATLAB. I am looking for a quadruple precision in MATLAB.I need more precision than offered by the standard double data type in MATLAB. I am looking for a quadruple precision in MATLAB. I need more precision than offered by the standard double data type in MATLAB. I am looking for a quadruple precision in MATLAB. 128-bit, quadruple_precision, float, double MATLAB Answers — New Questions
Why do I get “Code generation information file does not exist” as the “Rebuild Reason” when building my model?
When I successfully build our model I get "Code generation information file does not exist" as "Rebuild Reason".
Build Summary
Top model targets built:
Model | Action |Rebuild Reason
====================================================================
modelName | Code generated | Code generation information file does not exist.
1 of 1 models built (0 models already up to date)
Why is this and how can I remedy it?When I successfully build our model I get "Code generation information file does not exist" as "Rebuild Reason".
Build Summary
Top model targets built:
Model | Action |Rebuild Reason
====================================================================
modelName | Code generated | Code generation information file does not exist.
1 of 1 models built (0 models already up to date)
Why is this and how can I remedy it? When I successfully build our model I get "Code generation information file does not exist" as "Rebuild Reason".
Build Summary
Top model targets built:
Model | Action |Rebuild Reason
====================================================================
modelName | Code generated | Code generation information file does not exist.
1 of 1 models built (0 models already up to date)
Why is this and how can I remedy it? MATLAB Answers — New Questions
Why do I get the error message “#error Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE” when building a model with an S-function?
I have a Simulink R2018b model which contains an S-function. The S-function is a MEX S-Function. When I try to build the model, I get the following error message:
#error Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE
I am using Visual Studio 2017 as a compiler.I have a Simulink R2018b model which contains an S-function. The S-function is a MEX S-Function. When I try to build the model, I get the following error message:
#error Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE
I am using Visual Studio 2017 as a compiler. I have a Simulink R2018b model which contains an S-function. The S-function is a MEX S-Function. When I try to build the model, I get the following error message:
#error Must define one of RT, NRT, MATLAB_MEX_FILE, SL_INTERNAL, or FIPXT_SHARED_MODULE
I am using Visual Studio 2017 as a compiler. external, ide, s-function, error, inlining, tlc, non-lined MATLAB Answers — New Questions
Simulate sine wave with timestep different than overall model timestep
Hello All,
I needed your help in understanding of where the mistake is and wanted to know how can I implement the following:
I have a simulink model running a certain fixed time step. And inside the model there is a sine wave function connected with a digital clock that is creating a sine wave with sample rate set to -1(inherit). Meaning it will use t=simulink model timestep. Instead of -1 I would like to use a time step which is faster than Simulink time step. I tried using different values but I am getting an error: "Digital Clock has an invalid sample time. Only constant (inf) or inherited (-1) sample times are allowed in the asynchronous subsystem".
Can you please suggest me what other options can I try?
Appreciate all your help and guidance.Hello All,
I needed your help in understanding of where the mistake is and wanted to know how can I implement the following:
I have a simulink model running a certain fixed time step. And inside the model there is a sine wave function connected with a digital clock that is creating a sine wave with sample rate set to -1(inherit). Meaning it will use t=simulink model timestep. Instead of -1 I would like to use a time step which is faster than Simulink time step. I tried using different values but I am getting an error: "Digital Clock has an invalid sample time. Only constant (inf) or inherited (-1) sample times are allowed in the asynchronous subsystem".
Can you please suggest me what other options can I try?
Appreciate all your help and guidance. Hello All,
I needed your help in understanding of where the mistake is and wanted to know how can I implement the following:
I have a simulink model running a certain fixed time step. And inside the model there is a sine wave function connected with a digital clock that is creating a sine wave with sample rate set to -1(inherit). Meaning it will use t=simulink model timestep. Instead of -1 I would like to use a time step which is faster than Simulink time step. I tried using different values but I am getting an error: "Digital Clock has an invalid sample time. Only constant (inf) or inherited (-1) sample times are allowed in the asynchronous subsystem".
Can you please suggest me what other options can I try?
Appreciate all your help and guidance. #simulink MATLAB Answers — New Questions
getting statistics from within a mask within an image
We have an image that represents data that only makes sense when it is analyzed in numerical format.
Specifically, the data needs to be analyzed as a function of radius as shown below
Im interested specifically in hte max and min values within each of the defined areas with respect to the center point.
Ive been looking at a few examples online and it seems this should work when you pull the data from a mask.
However, the issue is that I seem to be getting values that are not realistic.
How to get pixel value inside a circle – MATLAB Answers – MATLAB Central (mathworks.com)
how to draw circle in an image? – MATLAB Answers – MATLAB Central (mathworks.com)
this is what I am doing
clear
img = double(imread(‘img121.jpg’));; %no filtration
img = -(0.0316*img) +8.3; % we did this as we cant calibeate the film, we scan the same film over and over and it changes by 80pixels
img = imrotate(img, 90);
img = imgaussfilt(img ,1.5);
figure, imagesc(img )
axis image
height2 = 3.6
caxis([0 height2])
colorbar
title(‘ ‘)
impixelinfo
%# make sure the image doesn’t disappear if we plot something else
hold on
%https://www.mathworks.com/matlabcentral/answers/1931825-how-to-get-pixel-value-inside-a-circle
%below looks like what we want
%https://www.mathworks.com/matlabcentral/answers/1931825-how-to-get-pixel-value-inside-a-circle
%# define points (in matrix coordinates)
%3"
cpx = 2050;
cpy = 2020;
inchlist = [12,10.5,9,7.5,6,4.5];
%draw lines on heel axis
for n=1:size(inchlist,2)
inch= inchlist(n)/4;
hcirc = drawcircle(‘Center’,[2050,2020],’Radius’,inch*590,’StripeColor’,’red’);
mask1 = hcirc.createMask;
maxval = (max(img(mask1)));
minval = (min(img(mask1)));
uniformity = maxval/minval
% p1 = [cpy-100,cpx+inch*590];
end
Even after getting this max and min value, I will need to remove 10 to get rid of noise. Extra credit if you can point me to a soluton for that too.
thank youWe have an image that represents data that only makes sense when it is analyzed in numerical format.
Specifically, the data needs to be analyzed as a function of radius as shown below
Im interested specifically in hte max and min values within each of the defined areas with respect to the center point.
Ive been looking at a few examples online and it seems this should work when you pull the data from a mask.
However, the issue is that I seem to be getting values that are not realistic.
How to get pixel value inside a circle – MATLAB Answers – MATLAB Central (mathworks.com)
how to draw circle in an image? – MATLAB Answers – MATLAB Central (mathworks.com)
this is what I am doing
clear
img = double(imread(‘img121.jpg’));; %no filtration
img = -(0.0316*img) +8.3; % we did this as we cant calibeate the film, we scan the same film over and over and it changes by 80pixels
img = imrotate(img, 90);
img = imgaussfilt(img ,1.5);
figure, imagesc(img )
axis image
height2 = 3.6
caxis([0 height2])
colorbar
title(‘ ‘)
impixelinfo
%# make sure the image doesn’t disappear if we plot something else
hold on
%https://www.mathworks.com/matlabcentral/answers/1931825-how-to-get-pixel-value-inside-a-circle
%below looks like what we want
%https://www.mathworks.com/matlabcentral/answers/1931825-how-to-get-pixel-value-inside-a-circle
%# define points (in matrix coordinates)
%3"
cpx = 2050;
cpy = 2020;
inchlist = [12,10.5,9,7.5,6,4.5];
%draw lines on heel axis
for n=1:size(inchlist,2)
inch= inchlist(n)/4;
hcirc = drawcircle(‘Center’,[2050,2020],’Radius’,inch*590,’StripeColor’,’red’);
mask1 = hcirc.createMask;
maxval = (max(img(mask1)));
minval = (min(img(mask1)));
uniformity = maxval/minval
% p1 = [cpy-100,cpx+inch*590];
end
Even after getting this max and min value, I will need to remove 10 to get rid of noise. Extra credit if you can point me to a soluton for that too.
thank you We have an image that represents data that only makes sense when it is analyzed in numerical format.
Specifically, the data needs to be analyzed as a function of radius as shown below
Im interested specifically in hte max and min values within each of the defined areas with respect to the center point.
Ive been looking at a few examples online and it seems this should work when you pull the data from a mask.
However, the issue is that I seem to be getting values that are not realistic.
How to get pixel value inside a circle – MATLAB Answers – MATLAB Central (mathworks.com)
how to draw circle in an image? – MATLAB Answers – MATLAB Central (mathworks.com)
this is what I am doing
clear
img = double(imread(‘img121.jpg’));; %no filtration
img = -(0.0316*img) +8.3; % we did this as we cant calibeate the film, we scan the same film over and over and it changes by 80pixels
img = imrotate(img, 90);
img = imgaussfilt(img ,1.5);
figure, imagesc(img )
axis image
height2 = 3.6
caxis([0 height2])
colorbar
title(‘ ‘)
impixelinfo
%# make sure the image doesn’t disappear if we plot something else
hold on
%https://www.mathworks.com/matlabcentral/answers/1931825-how-to-get-pixel-value-inside-a-circle
%below looks like what we want
%https://www.mathworks.com/matlabcentral/answers/1931825-how-to-get-pixel-value-inside-a-circle
%# define points (in matrix coordinates)
%3"
cpx = 2050;
cpy = 2020;
inchlist = [12,10.5,9,7.5,6,4.5];
%draw lines on heel axis
for n=1:size(inchlist,2)
inch= inchlist(n)/4;
hcirc = drawcircle(‘Center’,[2050,2020],’Radius’,inch*590,’StripeColor’,’red’);
mask1 = hcirc.createMask;
maxval = (max(img(mask1)));
minval = (min(img(mask1)));
uniformity = maxval/minval
% p1 = [cpy-100,cpx+inch*590];
end
Even after getting this max and min value, I will need to remove 10 to get rid of noise. Extra credit if you can point me to a soluton for that too.
thank you mask, statistics MATLAB Answers — New Questions
How to classify a folder of images?
I have a file contains a set of images including images of three denominations of currency. I need a MATLAB code to determine the number of images for each denomination of currency according to its features and colors.I have a file contains a set of images including images of three denominations of currency. I need a MATLAB code to determine the number of images for each denomination of currency according to its features and colors. I have a file contains a set of images including images of three denominations of currency. I need a MATLAB code to determine the number of images for each denomination of currency according to its features and colors. classify a folder of images MATLAB Answers — New Questions
how to modify code for distributed delay
I have a code, which gives a solution of a delay logistic equation with discrete delay.
tau = 1;
tspan = [0 20];
y0 = 0.5;
sol = dde23(@ddefunc, tau, y0, tspan);
% Plot the solution
figure;
plot(sol.x, sol.y, ‘LineWidth’, 2);
xlabel(‘Time (days)’);
ylabel(‘Population’);
legend(‘y’);
% Define the delay differential equation
function g = ddefunc(t, y, Z)
r = 1.5;
y_tau = Z;
g = r * y * (1 – y_tau);
end
Now I want to modify my code for distributed delay as attached below.
Can someone guide me how to deal with distributed delayI have a code, which gives a solution of a delay logistic equation with discrete delay.
tau = 1;
tspan = [0 20];
y0 = 0.5;
sol = dde23(@ddefunc, tau, y0, tspan);
% Plot the solution
figure;
plot(sol.x, sol.y, ‘LineWidth’, 2);
xlabel(‘Time (days)’);
ylabel(‘Population’);
legend(‘y’);
% Define the delay differential equation
function g = ddefunc(t, y, Z)
r = 1.5;
y_tau = Z;
g = r * y * (1 – y_tau);
end
Now I want to modify my code for distributed delay as attached below.
Can someone guide me how to deal with distributed delay I have a code, which gives a solution of a delay logistic equation with discrete delay.
tau = 1;
tspan = [0 20];
y0 = 0.5;
sol = dde23(@ddefunc, tau, y0, tspan);
% Plot the solution
figure;
plot(sol.x, sol.y, ‘LineWidth’, 2);
xlabel(‘Time (days)’);
ylabel(‘Population’);
legend(‘y’);
% Define the delay differential equation
function g = ddefunc(t, y, Z)
r = 1.5;
y_tau = Z;
g = r * y * (1 – y_tau);
end
Now I want to modify my code for distributed delay as attached below.
Can someone guide me how to deal with distributed delay distributed delay, delay differentia equations, solve MATLAB Answers — New Questions
Sizeof double float int etc
Hello there,
I need to know how to find an equivallent function in Matlab to the sizeof function in c++.
For example, in c++ if I write sizeof(double) I would get the amount of memory needed to store a double.
I need something very similar with a matrix now. I will be storing bigger and bigger matrix and I need to find their size in the memory.
Could someone of you please help me?
all best,
:)Hello there,
I need to know how to find an equivallent function in Matlab to the sizeof function in c++.
For example, in c++ if I write sizeof(double) I would get the amount of memory needed to store a double.
I need something very similar with a matrix now. I will be storing bigger and bigger matrix and I need to find their size in the memory.
Could someone of you please help me?
all best,
🙂 Hello there,
I need to know how to find an equivallent function in Matlab to the sizeof function in c++.
For example, in c++ if I write sizeof(double) I would get the amount of memory needed to store a double.
I need something very similar with a matrix now. I will be storing bigger and bigger matrix and I need to find their size in the memory.
Could someone of you please help me?
all best,
🙂 sizeof, memory, size MATLAB Answers — New Questions
To RESHAPE number of elements must not change
Hi all, im trying to do simple ERP study using EEGLAB. To RESHAPE number of elements must not change, such an error messahe was thrown. let me know how to fix it. ThanksHi all, im trying to do simple ERP study using EEGLAB. To RESHAPE number of elements must not change, such an error messahe was thrown. let me know how to fix it. Thanks Hi all, im trying to do simple ERP study using EEGLAB. To RESHAPE number of elements must not change, such an error messahe was thrown. let me know how to fix it. Thanks please help MATLAB Answers — New Questions
How to datasample exponential data without losing the exponential decay?
Hi all!
So this is the question:
I have a Table with one column (std_spk_avg, attached). This column has 400 numbers. The data follow exponential distribution, so when i normally resample using ‘resample’ function in matlab to obtain 1000 iterations, i lose the exponential decay in each iteration…
How can i code with this function so as not to lose the exponential decay in my 1000 iterations?
Thanks you all in advance :)Hi all!
So this is the question:
I have a Table with one column (std_spk_avg, attached). This column has 400 numbers. The data follow exponential distribution, so when i normally resample using ‘resample’ function in matlab to obtain 1000 iterations, i lose the exponential decay in each iteration…
How can i code with this function so as not to lose the exponential decay in my 1000 iterations?
Thanks you all in advance 🙂 Hi all!
So this is the question:
I have a Table with one column (std_spk_avg, attached). This column has 400 numbers. The data follow exponential distribution, so when i normally resample using ‘resample’ function in matlab to obtain 1000 iterations, i lose the exponential decay in each iteration…
How can i code with this function so as not to lose the exponential decay in my 1000 iterations?
Thanks you all in advance 🙂 datasample, exponential, table, exponential data, struct MATLAB Answers — New Questions
how to organize input dimensions for LSTM classification
Hi guys,
I’m trying to train a lstm using sequential data to predict classes, and I’m a little confused by the format of input data and labels.
For the sake of simplicity, I’ll use an example to mimic my situation.
let’s say I’m trying to use temperature data to predict 3 cities: A, B, and C.
Within each city, i have temperature readings from 10 therometers over 2 seconds at a sample frequency of 100 hz.
So far, at each observation, I have a 200 by 10 matrix (time point by therometer).
temperature_matrix = randi(40, 200, 10) % pseudodata
We collected the temperature data 40 times throughout the day at each city, and this will give us 120 observations (3 cities * 40). Within each observation, I have a 200 by 10 matrix.
As for my input format, I now have a 120 by 1 cell array, and again within each cell array is a 200 by 10 matrix.
temperature_input = cell(120,1)
for ii = 1:length(temperature_input)
temperature_input{ii} = randi(40, 200, 10)
end
labels = [repmat("city A", 40,1); repmat("city B", 40,1); repmat("city C", 40,1)]
Per my undstanding, if I were to have a time step of 10, i should make a sliding window with a size of 5, and move it down the time dimenssion at a moving step of 1. That is to say, for each 200 by 10 temperature_matrix, I now slice it into 196 2D arrays, where each array is 5 by 10 (window size by therometer).
My question is how this sliding window plays a part in the input format? the sliding window create the fourth dimension in my example. The other three dimension is observation, time, and therometer. I think my overall structure is still a 120 by 1 cell array, but the dimenssions within each entry, I dont know how to organize them.
Also, out of curiosity, will it mess up the structure i transpose the time point by therometer matrice? I’m only asking between I’ve seen examples on the sequencce either in row or column.
Best,
FYHi guys,
I’m trying to train a lstm using sequential data to predict classes, and I’m a little confused by the format of input data and labels.
For the sake of simplicity, I’ll use an example to mimic my situation.
let’s say I’m trying to use temperature data to predict 3 cities: A, B, and C.
Within each city, i have temperature readings from 10 therometers over 2 seconds at a sample frequency of 100 hz.
So far, at each observation, I have a 200 by 10 matrix (time point by therometer).
temperature_matrix = randi(40, 200, 10) % pseudodata
We collected the temperature data 40 times throughout the day at each city, and this will give us 120 observations (3 cities * 40). Within each observation, I have a 200 by 10 matrix.
As for my input format, I now have a 120 by 1 cell array, and again within each cell array is a 200 by 10 matrix.
temperature_input = cell(120,1)
for ii = 1:length(temperature_input)
temperature_input{ii} = randi(40, 200, 10)
end
labels = [repmat("city A", 40,1); repmat("city B", 40,1); repmat("city C", 40,1)]
Per my undstanding, if I were to have a time step of 10, i should make a sliding window with a size of 5, and move it down the time dimenssion at a moving step of 1. That is to say, for each 200 by 10 temperature_matrix, I now slice it into 196 2D arrays, where each array is 5 by 10 (window size by therometer).
My question is how this sliding window plays a part in the input format? the sliding window create the fourth dimension in my example. The other three dimension is observation, time, and therometer. I think my overall structure is still a 120 by 1 cell array, but the dimenssions within each entry, I dont know how to organize them.
Also, out of curiosity, will it mess up the structure i transpose the time point by therometer matrice? I’m only asking between I’ve seen examples on the sequencce either in row or column.
Best,
FY Hi guys,
I’m trying to train a lstm using sequential data to predict classes, and I’m a little confused by the format of input data and labels.
For the sake of simplicity, I’ll use an example to mimic my situation.
let’s say I’m trying to use temperature data to predict 3 cities: A, B, and C.
Within each city, i have temperature readings from 10 therometers over 2 seconds at a sample frequency of 100 hz.
So far, at each observation, I have a 200 by 10 matrix (time point by therometer).
temperature_matrix = randi(40, 200, 10) % pseudodata
We collected the temperature data 40 times throughout the day at each city, and this will give us 120 observations (3 cities * 40). Within each observation, I have a 200 by 10 matrix.
As for my input format, I now have a 120 by 1 cell array, and again within each cell array is a 200 by 10 matrix.
temperature_input = cell(120,1)
for ii = 1:length(temperature_input)
temperature_input{ii} = randi(40, 200, 10)
end
labels = [repmat("city A", 40,1); repmat("city B", 40,1); repmat("city C", 40,1)]
Per my undstanding, if I were to have a time step of 10, i should make a sliding window with a size of 5, and move it down the time dimenssion at a moving step of 1. That is to say, for each 200 by 10 temperature_matrix, I now slice it into 196 2D arrays, where each array is 5 by 10 (window size by therometer).
My question is how this sliding window plays a part in the input format? the sliding window create the fourth dimension in my example. The other three dimension is observation, time, and therometer. I think my overall structure is still a 120 by 1 cell array, but the dimenssions within each entry, I dont know how to organize them.
Also, out of curiosity, will it mess up the structure i transpose the time point by therometer matrice? I’m only asking between I’ve seen examples on the sequencce either in row or column.
Best,
FY lstm, input, dimension MATLAB Answers — New Questions
How to create a component reference in the system composer from a simscape component
Hello,
I have a Simscape Isothermal Fluid component that is an isolated component (it have its own test harness, test cases and requirements. You can see it is composed with simscape signals and simulink signals.
I would like to build a system composer, were this component is part of. But when I add a "reference component" on the system composer ad link to the compoenent, the physical lines does not come.
The only way I made it works is creating the sismcape compoenent inside the system composer, but this way I need to manage changes and so on inside the composer.
Any solution to create a simscape component that can be referenced inside the system composer and have the physical connections available?Hello,
I have a Simscape Isothermal Fluid component that is an isolated component (it have its own test harness, test cases and requirements. You can see it is composed with simscape signals and simulink signals.
I would like to build a system composer, were this component is part of. But when I add a "reference component" on the system composer ad link to the compoenent, the physical lines does not come.
The only way I made it works is creating the sismcape compoenent inside the system composer, but this way I need to manage changes and so on inside the composer.
Any solution to create a simscape component that can be referenced inside the system composer and have the physical connections available? Hello,
I have a Simscape Isothermal Fluid component that is an isolated component (it have its own test harness, test cases and requirements. You can see it is composed with simscape signals and simulink signals.
I would like to build a system composer, were this component is part of. But when I add a "reference component" on the system composer ad link to the compoenent, the physical lines does not come.
The only way I made it works is creating the sismcape compoenent inside the system composer, but this way I need to manage changes and so on inside the composer.
Any solution to create a simscape component that can be referenced inside the system composer and have the physical connections available? simscape, system composer MATLAB Answers — New Questions
In Simulink, How to decode CAN data with length greater than 8?
There is an issue using CAN Unpack to decode CAN message with length greater than 8. Is there any other recommanded way to decode CAN data? For starter, I have used bit extract and bitwise AND Shift Arithmetic to extract bits in simulink. I’m not sure if matlab function in simulink can also handle this if it’s possible.There is an issue using CAN Unpack to decode CAN message with length greater than 8. Is there any other recommanded way to decode CAN data? For starter, I have used bit extract and bitwise AND Shift Arithmetic to extract bits in simulink. I’m not sure if matlab function in simulink can also handle this if it’s possible. There is an issue using CAN Unpack to decode CAN message with length greater than 8. Is there any other recommanded way to decode CAN data? For starter, I have used bit extract and bitwise AND Shift Arithmetic to extract bits in simulink. I’m not sure if matlab function in simulink can also handle this if it’s possible. data, control MATLAB Answers — New Questions