Author: PuTI
.mltbx installer that works on multiple operating systems
I am trying to create a .mltbx installer that works on multiple operating systems. The content of the .mltbx has a library that needs to be system specific (.dll for windows, .so for linux and .dylib for macos). Is there a way to have same .mltbx installer be compatible with all systems including the fact that on macos needs to be compatible with both arm and x86_64 architectures ?
If this is possible can anyone point me to how can I do that ?
My ideal result is a way to make .mltbx package to use a diffrent path to the libInterface file based on the system but I was not able to find any way to do this.
Thanks!I am trying to create a .mltbx installer that works on multiple operating systems. The content of the .mltbx has a library that needs to be system specific (.dll for windows, .so for linux and .dylib for macos). Is there a way to have same .mltbx installer be compatible with all systems including the fact that on macos needs to be compatible with both arm and x86_64 architectures ?
If this is possible can anyone point me to how can I do that ?
My ideal result is a way to make .mltbx package to use a diffrent path to the libInterface file based on the system but I was not able to find any way to do this.
Thanks! I am trying to create a .mltbx installer that works on multiple operating systems. The content of the .mltbx has a library that needs to be system specific (.dll for windows, .so for linux and .dylib for macos). Is there a way to have same .mltbx installer be compatible with all systems including the fact that on macos needs to be compatible with both arm and x86_64 architectures ?
If this is possible can anyone point me to how can I do that ?
My ideal result is a way to make .mltbx package to use a diffrent path to the libInterface file based on the system but I was not able to find any way to do this.
Thanks! mltbx, system, macos, windows, linux MATLAB Answers — New Questions
How to read ‘.webp’ image file
Hi,
I have a couple of image files in ‘.webp’ format, how to read them in Matlab?Hi,
I have a couple of image files in ‘.webp’ format, how to read them in Matlab? Hi,
I have a couple of image files in ‘.webp’ format, how to read them in Matlab? webp, image file MATLAB Answers — New Questions
Measuring the luminosity of a picture?
Hi, I have to measure the luminosity of a picture using the l,a,b parameters, so I can compare the luminosity of several pictures. How would I go about to achieve this?Hi, I have to measure the luminosity of a picture using the l,a,b parameters, so I can compare the luminosity of several pictures. How would I go about to achieve this? Hi, I have to measure the luminosity of a picture using the l,a,b parameters, so I can compare the luminosity of several pictures. How would I go about to achieve this? luminosity, pictures, l a b MATLAB Answers — New Questions
Intended Re-definition of parameters in simulink, overshadowing of parameter values
In C-Code there is a way to define a parameter using the #ifndef pre-processor directive. Is there a way to replicate this mechanism in Simulink, using data dictionaries?
For example, assume a vehicle system consisting of various subsystems. For this example assume a brake control system and an engine control system. To perform their calculations, both systems require to know the parameter "VehicleMass", so they define it as a parameter in their models. However, when they get integrated in a higher level vehicle model, the "VehicleMass" should best be described on the vehicle model level, to avoid incompatible / inconsistent definitions. But if it is define on vehicle model level, from my understanding it is currently required to first delete the lower level definitions, in order to avoid re-definition failures.
That causes another issue though, because if either of those lower level models is meant to be re-used, it can not be guaranteed that the top level integration model will always provide this value. What if the lower level model is meant to be standalone?
In C-Code, #ifndef checks if a value is already defined. If yes, that higher value is used. If no, a definition is done at this level. This mechanism prevents the issue described above.
In addition to parameters, I am experiencing the same issue with datatype definitions, so the lower level models use a given enum, but that enum might also be available in an integration environment.In C-Code there is a way to define a parameter using the #ifndef pre-processor directive. Is there a way to replicate this mechanism in Simulink, using data dictionaries?
For example, assume a vehicle system consisting of various subsystems. For this example assume a brake control system and an engine control system. To perform their calculations, both systems require to know the parameter "VehicleMass", so they define it as a parameter in their models. However, when they get integrated in a higher level vehicle model, the "VehicleMass" should best be described on the vehicle model level, to avoid incompatible / inconsistent definitions. But if it is define on vehicle model level, from my understanding it is currently required to first delete the lower level definitions, in order to avoid re-definition failures.
That causes another issue though, because if either of those lower level models is meant to be re-used, it can not be guaranteed that the top level integration model will always provide this value. What if the lower level model is meant to be standalone?
In C-Code, #ifndef checks if a value is already defined. If yes, that higher value is used. If no, a definition is done at this level. This mechanism prevents the issue described above.
In addition to parameters, I am experiencing the same issue with datatype definitions, so the lower level models use a given enum, but that enum might also be available in an integration environment. In C-Code there is a way to define a parameter using the #ifndef pre-processor directive. Is there a way to replicate this mechanism in Simulink, using data dictionaries?
For example, assume a vehicle system consisting of various subsystems. For this example assume a brake control system and an engine control system. To perform their calculations, both systems require to know the parameter "VehicleMass", so they define it as a parameter in their models. However, when they get integrated in a higher level vehicle model, the "VehicleMass" should best be described on the vehicle model level, to avoid incompatible / inconsistent definitions. But if it is define on vehicle model level, from my understanding it is currently required to first delete the lower level definitions, in order to avoid re-definition failures.
That causes another issue though, because if either of those lower level models is meant to be re-used, it can not be guaranteed that the top level integration model will always provide this value. What if the lower level model is meant to be standalone?
In C-Code, #ifndef checks if a value is already defined. If yes, that higher value is used. If no, a definition is done at this level. This mechanism prevents the issue described above.
In addition to parameters, I am experiencing the same issue with datatype definitions, so the lower level models use a given enum, but that enum might also be available in an integration environment. parameter, simulink, data dictionary MATLAB Answers — New Questions
Find least binary palindrome greater than a natural number
I am looking for an efficient way to generate the least binary number, b, that yields a natural number greater than a given natural number, d.
A small example would be d = 15, binary = 1111, and for which the least largest b = 10001 (decimal value 17).
Assume the natural number of interest, d, is 1 quadrillion (10^15) for which the binary representation, b, is:
‘11100011010111111010100100110001101000000000000000’
I have tried one standard approach from the literature, which is to form the sum b + reverse(b) and check to see if the
result is a palindrome that yields a natural number that is just above d. So far, after many cycles, that hasn’t produced anything.
There is no guarantee this method will always work, for example, it fails for the number 196.
There is a wealth of tantalizing clues in the "OEIS," the Online Encyclopedia of Integer Sequences"
(for example: https://oeis.org/A006995) but nothing is given there in terms of MATLAB code.I am looking for an efficient way to generate the least binary number, b, that yields a natural number greater than a given natural number, d.
A small example would be d = 15, binary = 1111, and for which the least largest b = 10001 (decimal value 17).
Assume the natural number of interest, d, is 1 quadrillion (10^15) for which the binary representation, b, is:
‘11100011010111111010100100110001101000000000000000’
I have tried one standard approach from the literature, which is to form the sum b + reverse(b) and check to see if the
result is a palindrome that yields a natural number that is just above d. So far, after many cycles, that hasn’t produced anything.
There is no guarantee this method will always work, for example, it fails for the number 196.
There is a wealth of tantalizing clues in the "OEIS," the Online Encyclopedia of Integer Sequences"
(for example: https://oeis.org/A006995) but nothing is given there in terms of MATLAB code. I am looking for an efficient way to generate the least binary number, b, that yields a natural number greater than a given natural number, d.
A small example would be d = 15, binary = 1111, and for which the least largest b = 10001 (decimal value 17).
Assume the natural number of interest, d, is 1 quadrillion (10^15) for which the binary representation, b, is:
‘11100011010111111010100100110001101000000000000000’
I have tried one standard approach from the literature, which is to form the sum b + reverse(b) and check to see if the
result is a palindrome that yields a natural number that is just above d. So far, after many cycles, that hasn’t produced anything.
There is no guarantee this method will always work, for example, it fails for the number 196.
There is a wealth of tantalizing clues in the "OEIS," the Online Encyclopedia of Integer Sequences"
(for example: https://oeis.org/A006995) but nothing is given there in terms of MATLAB code. binary palindromes, number theory MATLAB Answers — New Questions
How to Simplify Passing Multiple Arguments from Structs in MATLAB Function Calls?
am working on a MATLAB project where I need to pass multiple arguments from two structs (n and d) to a function called mi_decode. Currently, I am passing each field individually, which makes the code quite verbose and hard to maintain. Here is a snippet of my current code:
function results = spectral_mi(labels, data, n, d)
d.pl_ u int8
d.prr_k cell
d.is_cnrm logical = true
d.is_chk logical = true
d.is_fbk logical = true
d.is_x logical = false
d.is_pl logical = false
d.is_prr logical = false
n.cl uint16 = numel(unique(labels))
n.t uint8 = size(data{1}, 2)
n.k uint8 = numel(data)
n.trials uint8 = numel(labels)
n.f uint8 = fix(size(data{1}, 2)/2)+1
n.pl uint16
% … other code …
pow_per_f = cell(1, n.f);
phase_per_f = cell(1, n.f);
for f = 1:n.f
pow_per_f{f} = squeeze(power(abs(st_data(:, f, :)), 2));
phase_per_f{f} = squeeze(angle(st_data(:, f, :)));
end
[mi_, zmi_, pmi_] = mi_decode( …
labels, pow_per_f{:}, …
"is_x", d.is_x, …
"t", n.t, …
"k", n.f, …
"pl", n.pl, …
"is_cnrm", d.is_cnrm, …
"is_chk", d.is_chk, …
"is_fbk", d.is_fbk, …
"is_pl", d.is_pl, …
"is_prr", d.is_prr);
[phase_mi_, phase_zmi_, phase_pmi_] = mi_decode( …
labels, phase_per_f{:}, …
"is_x", d.is_x, …
"t", n.t, …
"k", n.f, …
"pl", n.pl, …
"is_cnrm", d.is_cnrm, …
"is_chk", d.is_chk, …
"is_fbk", d.is_fbk, …
"is_pl", d.is_pl, …
"is_prr", d.is_prr);
end
Is there a more concise way to pass all the fields from the structs n and d to the mi_decode function without listing each field individually? Any suggestions or best practices for handling this in MATLAB would be greatly appreciated.am working on a MATLAB project where I need to pass multiple arguments from two structs (n and d) to a function called mi_decode. Currently, I am passing each field individually, which makes the code quite verbose and hard to maintain. Here is a snippet of my current code:
function results = spectral_mi(labels, data, n, d)
d.pl_ u int8
d.prr_k cell
d.is_cnrm logical = true
d.is_chk logical = true
d.is_fbk logical = true
d.is_x logical = false
d.is_pl logical = false
d.is_prr logical = false
n.cl uint16 = numel(unique(labels))
n.t uint8 = size(data{1}, 2)
n.k uint8 = numel(data)
n.trials uint8 = numel(labels)
n.f uint8 = fix(size(data{1}, 2)/2)+1
n.pl uint16
% … other code …
pow_per_f = cell(1, n.f);
phase_per_f = cell(1, n.f);
for f = 1:n.f
pow_per_f{f} = squeeze(power(abs(st_data(:, f, :)), 2));
phase_per_f{f} = squeeze(angle(st_data(:, f, :)));
end
[mi_, zmi_, pmi_] = mi_decode( …
labels, pow_per_f{:}, …
"is_x", d.is_x, …
"t", n.t, …
"k", n.f, …
"pl", n.pl, …
"is_cnrm", d.is_cnrm, …
"is_chk", d.is_chk, …
"is_fbk", d.is_fbk, …
"is_pl", d.is_pl, …
"is_prr", d.is_prr);
[phase_mi_, phase_zmi_, phase_pmi_] = mi_decode( …
labels, phase_per_f{:}, …
"is_x", d.is_x, …
"t", n.t, …
"k", n.f, …
"pl", n.pl, …
"is_cnrm", d.is_cnrm, …
"is_chk", d.is_chk, …
"is_fbk", d.is_fbk, …
"is_pl", d.is_pl, …
"is_prr", d.is_prr);
end
Is there a more concise way to pass all the fields from the structs n and d to the mi_decode function without listing each field individually? Any suggestions or best practices for handling this in MATLAB would be greatly appreciated. am working on a MATLAB project where I need to pass multiple arguments from two structs (n and d) to a function called mi_decode. Currently, I am passing each field individually, which makes the code quite verbose and hard to maintain. Here is a snippet of my current code:
function results = spectral_mi(labels, data, n, d)
d.pl_ u int8
d.prr_k cell
d.is_cnrm logical = true
d.is_chk logical = true
d.is_fbk logical = true
d.is_x logical = false
d.is_pl logical = false
d.is_prr logical = false
n.cl uint16 = numel(unique(labels))
n.t uint8 = size(data{1}, 2)
n.k uint8 = numel(data)
n.trials uint8 = numel(labels)
n.f uint8 = fix(size(data{1}, 2)/2)+1
n.pl uint16
% … other code …
pow_per_f = cell(1, n.f);
phase_per_f = cell(1, n.f);
for f = 1:n.f
pow_per_f{f} = squeeze(power(abs(st_data(:, f, :)), 2));
phase_per_f{f} = squeeze(angle(st_data(:, f, :)));
end
[mi_, zmi_, pmi_] = mi_decode( …
labels, pow_per_f{:}, …
"is_x", d.is_x, …
"t", n.t, …
"k", n.f, …
"pl", n.pl, …
"is_cnrm", d.is_cnrm, …
"is_chk", d.is_chk, …
"is_fbk", d.is_fbk, …
"is_pl", d.is_pl, …
"is_prr", d.is_prr);
[phase_mi_, phase_zmi_, phase_pmi_] = mi_decode( …
labels, phase_per_f{:}, …
"is_x", d.is_x, …
"t", n.t, …
"k", n.f, …
"pl", n.pl, …
"is_cnrm", d.is_cnrm, …
"is_chk", d.is_chk, …
"is_fbk", d.is_fbk, …
"is_pl", d.is_pl, …
"is_prr", d.is_prr);
end
Is there a more concise way to pass all the fields from the structs n and d to the mi_decode function without listing each field individually? Any suggestions or best practices for handling this in MATLAB would be greatly appreciated. struct, functions, arguments MATLAB Answers — New Questions
How to create polygonal mesh of a moving object in an image stack
I have image stack of moving object. How can I draw a polygonal mesh of this object?I have image stack of moving object. How can I draw a polygonal mesh of this object? I have image stack of moving object. How can I draw a polygonal mesh of this object? polygonal mesh MATLAB Answers — New Questions
Grey box model of 1d heat diffusion in a rod (official mathworks example)
Hello,
I’m thinking about grey-box modelling of heat diffusion in a rod with the 1d heat equation.
There is a interesting example at mathworls side:
https://de.mathworks.com/help/ident/ug/estimate-continuous-time-grey-box-model-for-heat-diffusion.html?status=SUCCESS
I would adapt the example (image: original) and change it a little bit to include a a convection to air at the left end of the rod (image: adapted).
Here is the code for the original version with the insulation at one end:
function [A,B,C,D,K,x0] = heatd(kappa,htf,T,Ngrid,L,temp)
% ODE file parameterizing the heat diffusion model
% kappa (first parameter) – heat diffusion coefficient
% htf (second parameter) – heat transfer coefficient
% at the far end of rod
% Auxiliary variables for computing state-space matrices:
% Ngrid: Number of points in the space-discretization
% L: Length of the rod
% temp: Initial room temperature (uniform)
% Compute space interval
deltaL = L/Ngrid;
% A matrix
A = zeros(Ngrid,Ngrid);
for kk = 2:Ngrid-1
A(kk,kk-1) = 1;
A(kk,kk) = -2;
A(kk,kk+1) = 1;
end
% Boundary condition on insulated end
A(1,1) = -1; A(1,2) = 1;
A(Ngrid,Ngrid-1) = 1;
A(Ngrid,Ngrid) = -1;
A = A*kappa/deltaL/deltaL;
% B matrix
B = zeros(Ngrid,1);
B(Ngrid,1) = htf/deltaL;
% C matrix
C = zeros(1,Ngrid);
C(1,1) = 1;
% D matrix (fixed to zero)
D = 0;
% K matrix: fixed to zero
K = zeros(Ngrid,1);
% Initial states: fixed to room temperature
x0 = temp*ones(Ngrid,1);
This section should be altered, but I’m not sure how to do it to include a known htc for air at the right end.
% Boundary condition on insulated end
A(1,1) = -1; A(1,2) = 1;
A(Ngrid,Ngrid-1) = 1;
A(Ngrid,Ngrid) = -1;
A = A*kappa/deltaL/deltaL;
Then the idgrey object is constructed:
m = idgrey(‘heatd’,{0.27 1},’c’,{10,1,22});
Another thing I don’t get is the structure of data. Unfortunately there is no explanation or example shown.
How can I implement my temperature data (for three points as two column table (t,T1) , (t,T2), (t,T3)) in the greyest?
me = greyest(data,m)
If I get it right, the parameters heat diffusion coefficient and heat transfer coefficient at the right end of rod are estimated, but I have to guess them as initial starting point? To do this the transient temperature data is required, unfortunately the example is incomplete.Hello,
I’m thinking about grey-box modelling of heat diffusion in a rod with the 1d heat equation.
There is a interesting example at mathworls side:
https://de.mathworks.com/help/ident/ug/estimate-continuous-time-grey-box-model-for-heat-diffusion.html?status=SUCCESS
I would adapt the example (image: original) and change it a little bit to include a a convection to air at the left end of the rod (image: adapted).
Here is the code for the original version with the insulation at one end:
function [A,B,C,D,K,x0] = heatd(kappa,htf,T,Ngrid,L,temp)
% ODE file parameterizing the heat diffusion model
% kappa (first parameter) – heat diffusion coefficient
% htf (second parameter) – heat transfer coefficient
% at the far end of rod
% Auxiliary variables for computing state-space matrices:
% Ngrid: Number of points in the space-discretization
% L: Length of the rod
% temp: Initial room temperature (uniform)
% Compute space interval
deltaL = L/Ngrid;
% A matrix
A = zeros(Ngrid,Ngrid);
for kk = 2:Ngrid-1
A(kk,kk-1) = 1;
A(kk,kk) = -2;
A(kk,kk+1) = 1;
end
% Boundary condition on insulated end
A(1,1) = -1; A(1,2) = 1;
A(Ngrid,Ngrid-1) = 1;
A(Ngrid,Ngrid) = -1;
A = A*kappa/deltaL/deltaL;
% B matrix
B = zeros(Ngrid,1);
B(Ngrid,1) = htf/deltaL;
% C matrix
C = zeros(1,Ngrid);
C(1,1) = 1;
% D matrix (fixed to zero)
D = 0;
% K matrix: fixed to zero
K = zeros(Ngrid,1);
% Initial states: fixed to room temperature
x0 = temp*ones(Ngrid,1);
This section should be altered, but I’m not sure how to do it to include a known htc for air at the right end.
% Boundary condition on insulated end
A(1,1) = -1; A(1,2) = 1;
A(Ngrid,Ngrid-1) = 1;
A(Ngrid,Ngrid) = -1;
A = A*kappa/deltaL/deltaL;
Then the idgrey object is constructed:
m = idgrey(‘heatd’,{0.27 1},’c’,{10,1,22});
Another thing I don’t get is the structure of data. Unfortunately there is no explanation or example shown.
How can I implement my temperature data (for three points as two column table (t,T1) , (t,T2), (t,T3)) in the greyest?
me = greyest(data,m)
If I get it right, the parameters heat diffusion coefficient and heat transfer coefficient at the right end of rod are estimated, but I have to guess them as initial starting point? To do this the transient temperature data is required, unfortunately the example is incomplete. Hello,
I’m thinking about grey-box modelling of heat diffusion in a rod with the 1d heat equation.
There is a interesting example at mathworls side:
https://de.mathworks.com/help/ident/ug/estimate-continuous-time-grey-box-model-for-heat-diffusion.html?status=SUCCESS
I would adapt the example (image: original) and change it a little bit to include a a convection to air at the left end of the rod (image: adapted).
Here is the code for the original version with the insulation at one end:
function [A,B,C,D,K,x0] = heatd(kappa,htf,T,Ngrid,L,temp)
% ODE file parameterizing the heat diffusion model
% kappa (first parameter) – heat diffusion coefficient
% htf (second parameter) – heat transfer coefficient
% at the far end of rod
% Auxiliary variables for computing state-space matrices:
% Ngrid: Number of points in the space-discretization
% L: Length of the rod
% temp: Initial room temperature (uniform)
% Compute space interval
deltaL = L/Ngrid;
% A matrix
A = zeros(Ngrid,Ngrid);
for kk = 2:Ngrid-1
A(kk,kk-1) = 1;
A(kk,kk) = -2;
A(kk,kk+1) = 1;
end
% Boundary condition on insulated end
A(1,1) = -1; A(1,2) = 1;
A(Ngrid,Ngrid-1) = 1;
A(Ngrid,Ngrid) = -1;
A = A*kappa/deltaL/deltaL;
% B matrix
B = zeros(Ngrid,1);
B(Ngrid,1) = htf/deltaL;
% C matrix
C = zeros(1,Ngrid);
C(1,1) = 1;
% D matrix (fixed to zero)
D = 0;
% K matrix: fixed to zero
K = zeros(Ngrid,1);
% Initial states: fixed to room temperature
x0 = temp*ones(Ngrid,1);
This section should be altered, but I’m not sure how to do it to include a known htc for air at the right end.
% Boundary condition on insulated end
A(1,1) = -1; A(1,2) = 1;
A(Ngrid,Ngrid-1) = 1;
A(Ngrid,Ngrid) = -1;
A = A*kappa/deltaL/deltaL;
Then the idgrey object is constructed:
m = idgrey(‘heatd’,{0.27 1},’c’,{10,1,22});
Another thing I don’t get is the structure of data. Unfortunately there is no explanation or example shown.
How can I implement my temperature data (for three points as two column table (t,T1) , (t,T2), (t,T3)) in the greyest?
me = greyest(data,m)
If I get it right, the parameters heat diffusion coefficient and heat transfer coefficient at the right end of rod are estimated, but I have to guess them as initial starting point? To do this the transient temperature data is required, unfortunately the example is incomplete. grey box, system identification, database, data import MATLAB Answers — New Questions
MatLab Home License on Multiple Computers
The license restrictions for the MatLab Home version are not very clear. So, can I…
– Install MatLab using a ‘Home’ license on multiple PCs, such as on my laptop and on my workstation?
– Can I download and install versions from different operating systems? For instance, the above installs PLUS an install on my Linux workstation?
Thanks.The license restrictions for the MatLab Home version are not very clear. So, can I…
– Install MatLab using a ‘Home’ license on multiple PCs, such as on my laptop and on my workstation?
– Can I download and install versions from different operating systems? For instance, the above installs PLUS an install on my Linux workstation?
Thanks. The license restrictions for the MatLab Home version are not very clear. So, can I…
– Install MatLab using a ‘Home’ license on multiple PCs, such as on my laptop and on my workstation?
– Can I download and install versions from different operating systems? For instance, the above installs PLUS an install on my Linux workstation?
Thanks. home, license MATLAB Answers — New Questions
Superimpose scatter data points on line charts in loop
Hi team. I have a simple script which takes in stock ticker from the my list and downloads histrorical data and then plots it on line chart (X axis is date, and Y axis is close price). I want to add scatter points on the dates when I bought securities. Example – If I bought stock A on 1/2/25 and 5/2/25 then I want my codes to show two dots on the line chart on these two dates. I know scatter needs second dimension so the x value will be the dates and y value should be what is there already on the line chart. I have attached a figure of what I want to achieve.
I have a list of securities (as shown in the image column "Name"), I would like to know best way to create a list for the dates that I want as scatters (as shown in image column "Purchased (scatter)"). Please advise how to create a list of dates which can have single or multiple dates for each securities (as shown in the image below). So when loop runs for security A it should then check for all dates for A and plot them as scatter before moving to security B in second iteraton. So total number of main loop iterations would be equal to number of securities I have in Name column.
My current code takes name from the list, downloads historical prices and then plots them on line chart in Loop.
Any help would be appreciated.
kind regards
AmitHi team. I have a simple script which takes in stock ticker from the my list and downloads histrorical data and then plots it on line chart (X axis is date, and Y axis is close price). I want to add scatter points on the dates when I bought securities. Example – If I bought stock A on 1/2/25 and 5/2/25 then I want my codes to show two dots on the line chart on these two dates. I know scatter needs second dimension so the x value will be the dates and y value should be what is there already on the line chart. I have attached a figure of what I want to achieve.
I have a list of securities (as shown in the image column "Name"), I would like to know best way to create a list for the dates that I want as scatters (as shown in image column "Purchased (scatter)"). Please advise how to create a list of dates which can have single or multiple dates for each securities (as shown in the image below). So when loop runs for security A it should then check for all dates for A and plot them as scatter before moving to security B in second iteraton. So total number of main loop iterations would be equal to number of securities I have in Name column.
My current code takes name from the list, downloads historical prices and then plots them on line chart in Loop.
Any help would be appreciated.
kind regards
Amit Hi team. I have a simple script which takes in stock ticker from the my list and downloads histrorical data and then plots it on line chart (X axis is date, and Y axis is close price). I want to add scatter points on the dates when I bought securities. Example – If I bought stock A on 1/2/25 and 5/2/25 then I want my codes to show two dots on the line chart on these two dates. I know scatter needs second dimension so the x value will be the dates and y value should be what is there already on the line chart. I have attached a figure of what I want to achieve.
I have a list of securities (as shown in the image column "Name"), I would like to know best way to create a list for the dates that I want as scatters (as shown in image column "Purchased (scatter)"). Please advise how to create a list of dates which can have single or multiple dates for each securities (as shown in the image below). So when loop runs for security A it should then check for all dates for A and plot them as scatter before moving to security B in second iteraton. So total number of main loop iterations would be equal to number of securities I have in Name column.
My current code takes name from the list, downloads historical prices and then plots them on line chart in Loop.
Any help would be appreciated.
kind regards
Amit scatter and line chart superimposed in one loop MATLAB Answers — New Questions
Why can’t the Scope read data in Simulink after disabling signal logging?
When using Simulink’s external mode to communicate with the DSP, I don’t want to log any data during communication, so I disabled signal logging.
However, I can no longer observe signals in the Scope during communication. How can I resolve this issue?When using Simulink’s external mode to communicate with the DSP, I don’t want to log any data during communication, so I disabled signal logging.
However, I can no longer observe signals in the Scope during communication. How can I resolve this issue? When using Simulink’s external mode to communicate with the DSP, I don’t want to log any data during communication, so I disabled signal logging.
However, I can no longer observe signals in the Scope during communication. How can I resolve this issue? simulink MATLAB Answers — New Questions
Hello, It’s pudding!! I’m new with Matlab and i’m using old version 2011a!!
Hello everyone ;
Please I need a help, i wrote a general code for determining natural frequencies and shape modes,but during the execution, i got a problem, no figure!!!
My pleasure if someone help me, please!! here is the code which i wrote it!!
%%%%—————-General Code——————-%%
clear
clc
close all
n=input(‘degrees of freedom’); %—-le nombre des masses—
M=zeros(n,n);
for i=1:n
M(i,i)=input(‘input la masse d elemnt’);
end
K=zeros(n,n);
disp(‘0 = pas deconnection’);
for i=1:n
K(i,i)=input(‘element de la raideur connecté à la terre’);
end
for i=1:n-1
for j=i+1:n
k=input(‘connection entre les elements de raideur’);
K(i,i)=K(i,i)+k;
K(i,j)=K(i,j)-k;
K(j,i)=K(j,i)-k;
K(j,j)=K(j,j)+k;
end
end
%%———-Calcul de vitesse angulaire naturelle———%%
[V,D]=eig(K,M);
omega=diag(D).^0.5;
freq_nat=omega/2*pi;
F = cell(numel(n),1);%%– forces’ vectors%%
%%%%%———Determination of eigenvalues——–%%%
C=zeros(n,n);
disp(‘0 = pas deconnection’);
for i=1:n
C(i,i)=input(‘element d amortisseur connecté à la terre’);
end
for i=1:n-1
for j=i+1:n
k=input(‘connection entre les elements damortisseur’);
C(i,i)=C(i,i)+k;
C(i,j)=C(i,j)-k;
C(j,i)=C(j,i)-k;
C(j,j)=C(j,j)+k;
end
end
%%%%————Fréquences propres amorties———%%%
A=[zeros(n,n),M;M,C];
B=[-M,zeros(n,n);zeros(n,n),K];
[V,D]=eig(full(B),full(A));
[omega,tmp]=sort(sqrt(diag(imag(D))),’ascend’);
freq_nat=omega/2/pi;
[mode,tmp]=sort((V),’ascend’);
%%%for i=1:n
%%V(:,i)=V(:,i)/V(n,i);
%end
for i=1:length(D)
zeta(i)=-(real(D(i)))/(imag(D(i)));
end
for i=1:length(D)
plot(freq_nat(i),zeta(i));
xlabel(‘frequences naturelles’);
ylabel(‘coefficient damortissement’);
end
for i=1:length(V)
plot(V(:,i));
figure()
hold on
title(‘mode (i)’)
hold off
xlabel(‘overturning moment’);
ylabel(”);
endHello everyone ;
Please I need a help, i wrote a general code for determining natural frequencies and shape modes,but during the execution, i got a problem, no figure!!!
My pleasure if someone help me, please!! here is the code which i wrote it!!
%%%%—————-General Code——————-%%
clear
clc
close all
n=input(‘degrees of freedom’); %—-le nombre des masses—
M=zeros(n,n);
for i=1:n
M(i,i)=input(‘input la masse d elemnt’);
end
K=zeros(n,n);
disp(‘0 = pas deconnection’);
for i=1:n
K(i,i)=input(‘element de la raideur connecté à la terre’);
end
for i=1:n-1
for j=i+1:n
k=input(‘connection entre les elements de raideur’);
K(i,i)=K(i,i)+k;
K(i,j)=K(i,j)-k;
K(j,i)=K(j,i)-k;
K(j,j)=K(j,j)+k;
end
end
%%———-Calcul de vitesse angulaire naturelle———%%
[V,D]=eig(K,M);
omega=diag(D).^0.5;
freq_nat=omega/2*pi;
F = cell(numel(n),1);%%– forces’ vectors%%
%%%%%———Determination of eigenvalues——–%%%
C=zeros(n,n);
disp(‘0 = pas deconnection’);
for i=1:n
C(i,i)=input(‘element d amortisseur connecté à la terre’);
end
for i=1:n-1
for j=i+1:n
k=input(‘connection entre les elements damortisseur’);
C(i,i)=C(i,i)+k;
C(i,j)=C(i,j)-k;
C(j,i)=C(j,i)-k;
C(j,j)=C(j,j)+k;
end
end
%%%%————Fréquences propres amorties———%%%
A=[zeros(n,n),M;M,C];
B=[-M,zeros(n,n);zeros(n,n),K];
[V,D]=eig(full(B),full(A));
[omega,tmp]=sort(sqrt(diag(imag(D))),’ascend’);
freq_nat=omega/2/pi;
[mode,tmp]=sort((V),’ascend’);
%%%for i=1:n
%%V(:,i)=V(:,i)/V(n,i);
%end
for i=1:length(D)
zeta(i)=-(real(D(i)))/(imag(D(i)));
end
for i=1:length(D)
plot(freq_nat(i),zeta(i));
xlabel(‘frequences naturelles’);
ylabel(‘coefficient damortissement’);
end
for i=1:length(V)
plot(V(:,i));
figure()
hold on
title(‘mode (i)’)
hold off
xlabel(‘overturning moment’);
ylabel(”);
end Hello everyone ;
Please I need a help, i wrote a general code for determining natural frequencies and shape modes,but during the execution, i got a problem, no figure!!!
My pleasure if someone help me, please!! here is the code which i wrote it!!
%%%%—————-General Code——————-%%
clear
clc
close all
n=input(‘degrees of freedom’); %—-le nombre des masses—
M=zeros(n,n);
for i=1:n
M(i,i)=input(‘input la masse d elemnt’);
end
K=zeros(n,n);
disp(‘0 = pas deconnection’);
for i=1:n
K(i,i)=input(‘element de la raideur connecté à la terre’);
end
for i=1:n-1
for j=i+1:n
k=input(‘connection entre les elements de raideur’);
K(i,i)=K(i,i)+k;
K(i,j)=K(i,j)-k;
K(j,i)=K(j,i)-k;
K(j,j)=K(j,j)+k;
end
end
%%———-Calcul de vitesse angulaire naturelle———%%
[V,D]=eig(K,M);
omega=diag(D).^0.5;
freq_nat=omega/2*pi;
F = cell(numel(n),1);%%– forces’ vectors%%
%%%%%———Determination of eigenvalues——–%%%
C=zeros(n,n);
disp(‘0 = pas deconnection’);
for i=1:n
C(i,i)=input(‘element d amortisseur connecté à la terre’);
end
for i=1:n-1
for j=i+1:n
k=input(‘connection entre les elements damortisseur’);
C(i,i)=C(i,i)+k;
C(i,j)=C(i,j)-k;
C(j,i)=C(j,i)-k;
C(j,j)=C(j,j)+k;
end
end
%%%%————Fréquences propres amorties———%%%
A=[zeros(n,n),M;M,C];
B=[-M,zeros(n,n);zeros(n,n),K];
[V,D]=eig(full(B),full(A));
[omega,tmp]=sort(sqrt(diag(imag(D))),’ascend’);
freq_nat=omega/2/pi;
[mode,tmp]=sort((V),’ascend’);
%%%for i=1:n
%%V(:,i)=V(:,i)/V(n,i);
%end
for i=1:length(D)
zeta(i)=-(real(D(i)))/(imag(D(i)));
end
for i=1:length(D)
plot(freq_nat(i),zeta(i));
xlabel(‘frequences naturelles’);
ylabel(‘coefficient damortissement’);
end
for i=1:length(V)
plot(V(:,i));
figure()
hold on
title(‘mode (i)’)
hold off
xlabel(‘overturning moment’);
ylabel(”);
end general code, natural frequencies, mode shapes, critical speeds MATLAB Answers — New Questions
how to create dataset for classification and pattern recognition (neural network)
Dear all
I have a table of extracted features from the image.
I need to create a dataset to use it in classification and pattern recognition.
I have many images and i will group them according to disease stage to 4 or 5 groups or classes. could you help me how to create the dataset (inputs and targets) and if there some advice to create a good classifier and have a good results.
thank youDear all
I have a table of extracted features from the image.
I need to create a dataset to use it in classification and pattern recognition.
I have many images and i will group them according to disease stage to 4 or 5 groups or classes. could you help me how to create the dataset (inputs and targets) and if there some advice to create a good classifier and have a good results.
thank you Dear all
I have a table of extracted features from the image.
I need to create a dataset to use it in classification and pattern recognition.
I have many images and i will group them according to disease stage to 4 or 5 groups or classes. could you help me how to create the dataset (inputs and targets) and if there some advice to create a good classifier and have a good results.
thank you dataset, classifier, pattern recoginition MATLAB Answers — New Questions
How to perform 2-way repeated-measures Manova using RepeatedMeasuresModel?
Hi,
I’m currently stuck on performing a two-way repeated-measures Manova in Matlab using the RepeatedMeasuresModel. My data set consists of six units, from each of which I measured three properties, which might be highly correlated. Each unit was tested using two within-subject factors each of which has two levels (4 conditions in total). Thus, my data table consists of six rows and twelve columns (3 properties * 4 conditions).
I created the within-table as follows:
within = table({‘A’;’A’;’A’;’A’;’B’;’B’;’B’;’B’;’C’;’C’;’C’;’C’},…
{‘1′;’2′;’1′;’2′;’1′;’2′;’1′;’2′;’1′;’2′;’1′;’2’},…
{‘a’;’a’;’b’;’b’;’a’;’a’;’b’;’b’;’a’;’a’;’b’;’b’},…
‘VariableNames’,{‘Property’,’Condition1′,’Condition2′});
The table looks like:
Property Condition1 Condition2
________ __________ __________
‘A’ ‘1’ ‘a’
‘A’ ‘2’ ‘a’
‘A’ ‘1’ ‘b’
‘A’ ‘2’ ‘b’
‘B’ ‘1’ ‘a’
‘B’ ‘2’ ‘a’
‘B’ ‘1’ ‘b’
‘B’ ‘2’ ‘b’
‘C’ ‘1’ ‘a’
‘C’ ‘2’ ‘a’
‘C’ ‘1’ ‘b’
‘C’ ‘2’ ‘b’
The repeated-measures Model I created using
rm = fitrm(t,’M1-M12~1′,’withinDesign’,within);
where t is the data table and M1-M12 are the responses.
If I now use
manova(rm)
the output looks like this:
Statistic Value F RSquare df1 df2 pValue
_________ _______ ___ _______ ___ ___ ______
Pillai 0.54237 0 0.54237 6 0 NaN
Wilks NaN NaN NaN 6 0 NaN
Hotelling NaN NaN NaN 6 NaN NaN
Roy Inf NaN NaN 6 0 NaN
I don’t know, how I can specify, which of my within-subject factors are the different properties and which ones are the different conditions.
Help of any kind would be highly appreciated.
Best,
ChristianHi,
I’m currently stuck on performing a two-way repeated-measures Manova in Matlab using the RepeatedMeasuresModel. My data set consists of six units, from each of which I measured three properties, which might be highly correlated. Each unit was tested using two within-subject factors each of which has two levels (4 conditions in total). Thus, my data table consists of six rows and twelve columns (3 properties * 4 conditions).
I created the within-table as follows:
within = table({‘A’;’A’;’A’;’A’;’B’;’B’;’B’;’B’;’C’;’C’;’C’;’C’},…
{‘1′;’2′;’1′;’2′;’1′;’2′;’1′;’2′;’1′;’2′;’1′;’2’},…
{‘a’;’a’;’b’;’b’;’a’;’a’;’b’;’b’;’a’;’a’;’b’;’b’},…
‘VariableNames’,{‘Property’,’Condition1′,’Condition2′});
The table looks like:
Property Condition1 Condition2
________ __________ __________
‘A’ ‘1’ ‘a’
‘A’ ‘2’ ‘a’
‘A’ ‘1’ ‘b’
‘A’ ‘2’ ‘b’
‘B’ ‘1’ ‘a’
‘B’ ‘2’ ‘a’
‘B’ ‘1’ ‘b’
‘B’ ‘2’ ‘b’
‘C’ ‘1’ ‘a’
‘C’ ‘2’ ‘a’
‘C’ ‘1’ ‘b’
‘C’ ‘2’ ‘b’
The repeated-measures Model I created using
rm = fitrm(t,’M1-M12~1′,’withinDesign’,within);
where t is the data table and M1-M12 are the responses.
If I now use
manova(rm)
the output looks like this:
Statistic Value F RSquare df1 df2 pValue
_________ _______ ___ _______ ___ ___ ______
Pillai 0.54237 0 0.54237 6 0 NaN
Wilks NaN NaN NaN 6 0 NaN
Hotelling NaN NaN NaN 6 NaN NaN
Roy Inf NaN NaN 6 0 NaN
I don’t know, how I can specify, which of my within-subject factors are the different properties and which ones are the different conditions.
Help of any kind would be highly appreciated.
Best,
Christian Hi,
I’m currently stuck on performing a two-way repeated-measures Manova in Matlab using the RepeatedMeasuresModel. My data set consists of six units, from each of which I measured three properties, which might be highly correlated. Each unit was tested using two within-subject factors each of which has two levels (4 conditions in total). Thus, my data table consists of six rows and twelve columns (3 properties * 4 conditions).
I created the within-table as follows:
within = table({‘A’;’A’;’A’;’A’;’B’;’B’;’B’;’B’;’C’;’C’;’C’;’C’},…
{‘1′;’2′;’1′;’2′;’1′;’2′;’1′;’2′;’1′;’2′;’1′;’2’},…
{‘a’;’a’;’b’;’b’;’a’;’a’;’b’;’b’;’a’;’a’;’b’;’b’},…
‘VariableNames’,{‘Property’,’Condition1′,’Condition2′});
The table looks like:
Property Condition1 Condition2
________ __________ __________
‘A’ ‘1’ ‘a’
‘A’ ‘2’ ‘a’
‘A’ ‘1’ ‘b’
‘A’ ‘2’ ‘b’
‘B’ ‘1’ ‘a’
‘B’ ‘2’ ‘a’
‘B’ ‘1’ ‘b’
‘B’ ‘2’ ‘b’
‘C’ ‘1’ ‘a’
‘C’ ‘2’ ‘a’
‘C’ ‘1’ ‘b’
‘C’ ‘2’ ‘b’
The repeated-measures Model I created using
rm = fitrm(t,’M1-M12~1′,’withinDesign’,within);
where t is the data table and M1-M12 are the responses.
If I now use
manova(rm)
the output looks like this:
Statistic Value F RSquare df1 df2 pValue
_________ _______ ___ _______ ___ ___ ______
Pillai 0.54237 0 0.54237 6 0 NaN
Wilks NaN NaN NaN 6 0 NaN
Hotelling NaN NaN NaN 6 NaN NaN
Roy Inf NaN NaN 6 0 NaN
I don’t know, how I can specify, which of my within-subject factors are the different properties and which ones are the different conditions.
Help of any kind would be highly appreciated.
Best,
Christian manova, repeatedmeasures MATLAB Answers — New Questions
When using bootstrp, are paired variables resampled together?
In looking at the example for bootstrp in the documentation, two variables include lsat and gpa (http://www.mathworks.com/help/stats/bootstrp.html). Do the values for these variables stay paired (the data points are resampled versus each variable is resampled separately)? For instance, if a person has an LSAT score of 115 and a GPA of 3.6, when that data point is resampled subsequently, will 115 and 3.6 stay paired, or are the two variables resampled independently?In looking at the example for bootstrp in the documentation, two variables include lsat and gpa (http://www.mathworks.com/help/stats/bootstrp.html). Do the values for these variables stay paired (the data points are resampled versus each variable is resampled separately)? For instance, if a person has an LSAT score of 115 and a GPA of 3.6, when that data point is resampled subsequently, will 115 and 3.6 stay paired, or are the two variables resampled independently? In looking at the example for bootstrp in the documentation, two variables include lsat and gpa (http://www.mathworks.com/help/stats/bootstrp.html). Do the values for these variables stay paired (the data points are resampled versus each variable is resampled separately)? For instance, if a person has an LSAT score of 115 and a GPA of 3.6, when that data point is resampled subsequently, will 115 and 3.6 stay paired, or are the two variables resampled independently? statistics, bootstrap MATLAB Answers — New Questions
Desktop window log out before open it
few day before, i was unable to open desktop window on PC. I have tried any answer form Math Work, but still failed. than i decided to reinstall the computer and installed again. After installed desktop window, i logged my friend’s account (cause i can’t recive the verify mail). Everything is down.
here is the problem
if my desktop window can open is system promblem, which is easy to slove.
What if the problem is the account verify fail cause desktop window don’t show up. How to log out my account before open Matlab desktop window ?few day before, i was unable to open desktop window on PC. I have tried any answer form Math Work, but still failed. than i decided to reinstall the computer and installed again. After installed desktop window, i logged my friend’s account (cause i can’t recive the verify mail). Everything is down.
here is the problem
if my desktop window can open is system promblem, which is easy to slove.
What if the problem is the account verify fail cause desktop window don’t show up. How to log out my account before open Matlab desktop window ? few day before, i was unable to open desktop window on PC. I have tried any answer form Math Work, but still failed. than i decided to reinstall the computer and installed again. After installed desktop window, i logged my friend’s account (cause i can’t recive the verify mail). Everything is down.
here is the problem
if my desktop window can open is system promblem, which is easy to slove.
What if the problem is the account verify fail cause desktop window don’t show up. How to log out my account before open Matlab desktop window ? log in/out MATLAB Answers — New Questions
Securing Container Workloads on Azure Container Apps (ACA)
Azure Container Apps (ACA) is a serverless platform for scalable containerized applications, while abstracting the underlying infrastructure. Since it runs without providing access to its underlying operating system, it has inherent security benefits, but it also presents a challenge for security and compliance tools that were not purpose-built to support such an environment. Aqua is a certified security solution for ACA – read on to see how we do it.
Azure Container Apps (ACA) is a serverless platform for scalable containerized applications, while abstracting the underlying infrastructure. Since it runs without providing access to its underlying operating system, it has inherent security benefits, but it also presents a challenge for security and compliance tools that were not purpose-built to support such an environment. Aqua is a certified security solution for ACA – read on to see how we do it.
Read More
Plot first terms of Fourier series and amplitude
Hello,
how can I plot the first k terms of a Fourier series on the same graph (without showing the Gibb’s effect). I would also like to plot the amplitude of those terms over frequency. I want the graphs on the attached picture. How can I make them with Matlab?
Thanks in advanceHello,
how can I plot the first k terms of a Fourier series on the same graph (without showing the Gibb’s effect). I would also like to plot the amplitude of those terms over frequency. I want the graphs on the attached picture. How can I make them with Matlab?
Thanks in advance Hello,
how can I plot the first k terms of a Fourier series on the same graph (without showing the Gibb’s effect). I would also like to plot the amplitude of those terms over frequency. I want the graphs on the attached picture. How can I make them with Matlab?
Thanks in advance fourier, plotting MATLAB Answers — New Questions
fminunc step size too small
Hello Matlab community,
I am using fminunc to fit a function to a set of datapoints. The optimizer stops due to small step size however I have noticed the steps it is taking are way too small. I don’t want to set the minimum step size lower than 1e-3 but if I do so it just stops immediately.
The solution I have found is to provide the function with my own calculated gradient and manually multiplying it by 1e6.
Is there an optimizer option that can rescale the step size to gradient ratio in a similar way?
My optimizer options are:
options = optimoptions(‘fminunc’, …
‘Display’, ‘iter’, …
‘Algorithm’, ‘trust-region’, …
‘HessianFcn’,’objective’, …
‘SpecifyObjectiveGradient’,true, …
‘StepTolerance’, 5e-3, …,
"FiniteDifferenceStepSize", 0.1, …,
"FunctionTolerance",0.00001, …
"OptimalityTolerance",2e-6/factor, …
‘MaxFunctionEvaluations’, 10000, …
‘MaxIterations’, 10000, …
‘OutputFcn’, @saveIterations);
Thank you in advance for your help!Hello Matlab community,
I am using fminunc to fit a function to a set of datapoints. The optimizer stops due to small step size however I have noticed the steps it is taking are way too small. I don’t want to set the minimum step size lower than 1e-3 but if I do so it just stops immediately.
The solution I have found is to provide the function with my own calculated gradient and manually multiplying it by 1e6.
Is there an optimizer option that can rescale the step size to gradient ratio in a similar way?
My optimizer options are:
options = optimoptions(‘fminunc’, …
‘Display’, ‘iter’, …
‘Algorithm’, ‘trust-region’, …
‘HessianFcn’,’objective’, …
‘SpecifyObjectiveGradient’,true, …
‘StepTolerance’, 5e-3, …,
"FiniteDifferenceStepSize", 0.1, …,
"FunctionTolerance",0.00001, …
"OptimalityTolerance",2e-6/factor, …
‘MaxFunctionEvaluations’, 10000, …
‘MaxIterations’, 10000, …
‘OutputFcn’, @saveIterations);
Thank you in advance for your help! Hello Matlab community,
I am using fminunc to fit a function to a set of datapoints. The optimizer stops due to small step size however I have noticed the steps it is taking are way too small. I don’t want to set the minimum step size lower than 1e-3 but if I do so it just stops immediately.
The solution I have found is to provide the function with my own calculated gradient and manually multiplying it by 1e6.
Is there an optimizer option that can rescale the step size to gradient ratio in a similar way?
My optimizer options are:
options = optimoptions(‘fminunc’, …
‘Display’, ‘iter’, …
‘Algorithm’, ‘trust-region’, …
‘HessianFcn’,’objective’, …
‘SpecifyObjectiveGradient’,true, …
‘StepTolerance’, 5e-3, …,
"FiniteDifferenceStepSize", 0.1, …,
"FunctionTolerance",0.00001, …
"OptimalityTolerance",2e-6/factor, …
‘MaxFunctionEvaluations’, 10000, …
‘MaxIterations’, 10000, …
‘OutputFcn’, @saveIterations);
Thank you in advance for your help! optimization, fminunc MATLAB Answers — New Questions
Using the command window as a serial monitor for arduino
I want to use the command window as a serial monitor to plot data sent by arduino or another device serially. I need to send some data to arduino too. I have the following code.
% lectura de puerto serial COM
clc;
clear;
close all;
%comandos de apertura del puerto serial
com_avr = serial(‘COM4’,115200);
fopen(com_avr);
while(1)
%para leer
data = readline(com_avr); disp(data); %para leer
data = readline(com_avr); disp(data);
str = input("Send to Arduino: ","s");
val = sscanf(str, "%f");
fprintf(com_avr, "%f", val);
%muestra lo que se envio
data = readline(com_avr); disp(data);
%HERE MUST TO PLOT THE DATA
while 1
data = readline(com_avr);
plot(x,data,’bd’,’LineWidth’,2)
axis([x-2 x 40 160])
hold on
drawnow
x = x + 0.002;
end
%secuencia de comandos de salida
if str == ‘z’
disp("exit")
break;
end
end
disp("closing communication…")
%finaliza la comunicacion serial y libera el puerto
close(com_avr);
What could I do to open a plot graph and plot the data sent from Arduino?
May you give me any sugestion to improve this code?I want to use the command window as a serial monitor to plot data sent by arduino or another device serially. I need to send some data to arduino too. I have the following code.
% lectura de puerto serial COM
clc;
clear;
close all;
%comandos de apertura del puerto serial
com_avr = serial(‘COM4’,115200);
fopen(com_avr);
while(1)
%para leer
data = readline(com_avr); disp(data); %para leer
data = readline(com_avr); disp(data);
str = input("Send to Arduino: ","s");
val = sscanf(str, "%f");
fprintf(com_avr, "%f", val);
%muestra lo que se envio
data = readline(com_avr); disp(data);
%HERE MUST TO PLOT THE DATA
while 1
data = readline(com_avr);
plot(x,data,’bd’,’LineWidth’,2)
axis([x-2 x 40 160])
hold on
drawnow
x = x + 0.002;
end
%secuencia de comandos de salida
if str == ‘z’
disp("exit")
break;
end
end
disp("closing communication…")
%finaliza la comunicacion serial y libera el puerto
close(com_avr);
What could I do to open a plot graph and plot the data sent from Arduino?
May you give me any sugestion to improve this code? I want to use the command window as a serial monitor to plot data sent by arduino or another device serially. I need to send some data to arduino too. I have the following code.
% lectura de puerto serial COM
clc;
clear;
close all;
%comandos de apertura del puerto serial
com_avr = serial(‘COM4’,115200);
fopen(com_avr);
while(1)
%para leer
data = readline(com_avr); disp(data); %para leer
data = readline(com_avr); disp(data);
str = input("Send to Arduino: ","s");
val = sscanf(str, "%f");
fprintf(com_avr, "%f", val);
%muestra lo que se envio
data = readline(com_avr); disp(data);
%HERE MUST TO PLOT THE DATA
while 1
data = readline(com_avr);
plot(x,data,’bd’,’LineWidth’,2)
axis([x-2 x 40 160])
hold on
drawnow
x = x + 0.002;
end
%secuencia de comandos de salida
if str == ‘z’
disp("exit")
break;
end
end
disp("closing communication…")
%finaliza la comunicacion serial y libera el puerto
close(com_avr);
What could I do to open a plot graph and plot the data sent from Arduino?
May you give me any sugestion to improve this code? arduino, serial MATLAB Answers — New Questions