Tag Archives: matlab
Can’t I import tdms file in R2023b?
Hello,
I installed R2023b version in my company PC.
I want to import TDMS file in R2023b but it happened error messages.
" Error using untitled
License not found. Data Acquisition Toolbox or Communications Toolbox is required to use TDMS feature."
I found that it can be imported from R2024a.
So, Isn’t there a licence of importing TDMS file in R2023b?
Please let me know.
Thank you.Hello,
I installed R2023b version in my company PC.
I want to import TDMS file in R2023b but it happened error messages.
" Error using untitled
License not found. Data Acquisition Toolbox or Communications Toolbox is required to use TDMS feature."
I found that it can be imported from R2024a.
So, Isn’t there a licence of importing TDMS file in R2023b?
Please let me know.
Thank you. Hello,
I installed R2023b version in my company PC.
I want to import TDMS file in R2023b but it happened error messages.
" Error using untitled
License not found. Data Acquisition Toolbox or Communications Toolbox is required to use TDMS feature."
I found that it can be imported from R2024a.
So, Isn’t there a licence of importing TDMS file in R2023b?
Please let me know.
Thank you. import, tdms file MATLAB Answers — New Questions
Setting bounds for constants in a fit() object in terms of other constants in the fit object
Hello, I am currently trying to fit experimental data that I theorize fits a logarithmic function.
To this end, I am using the fit() and fitoptions() function in order to create a logarithmic equation.
Since the default MATLAB logarithmic fit model does not seem to account for horizontal translation and scaling, I have created a custom fit type as seen below:
shiftedLog = fittype(‘A*log((B*x)-C) + D’, ‘independent’, ‘x’, ‘coefficients’, {‘A’,’B’,’C’,’D’});
% set the bounds
opts.StartPoint = […]; % Initial guesses for [A, B, C, D]
opts.Lower = […]; % Lower bounds for [A, B, C, D]
opts.Upper = […]; % Upper bounds for [A, B, C, D]
I have noticed that when I try to run this program, I have ran into errors where the fit object returns either infinity or a complex value.
Since the log() function is defined only when its inner argument > 0, I need to specify the bounds for variables B and C to keep the entire argument positive.
However, When I try to specify the bounds in terms of the constants of the fit object, for example:
opts.Lower = [-Inf, C/min(x),…]
MATLAB gives me an error.
I know that in the main script code, the constants A, B, C, and D are not standalone variables so the main script has this issue, but as (to my knowledge) fit() finds the best values for the constants through an iterative process. Given this, It is impractical to specify a hard-coded value for the limits.
How should I approach this problem? Is there another way to find fit of a logarithmic function that incorporates ‘shifting’ and ‘stretching’ in both horizontal and vertical directions? Or is there a workaround? Thank you in advance.Hello, I am currently trying to fit experimental data that I theorize fits a logarithmic function.
To this end, I am using the fit() and fitoptions() function in order to create a logarithmic equation.
Since the default MATLAB logarithmic fit model does not seem to account for horizontal translation and scaling, I have created a custom fit type as seen below:
shiftedLog = fittype(‘A*log((B*x)-C) + D’, ‘independent’, ‘x’, ‘coefficients’, {‘A’,’B’,’C’,’D’});
% set the bounds
opts.StartPoint = […]; % Initial guesses for [A, B, C, D]
opts.Lower = […]; % Lower bounds for [A, B, C, D]
opts.Upper = […]; % Upper bounds for [A, B, C, D]
I have noticed that when I try to run this program, I have ran into errors where the fit object returns either infinity or a complex value.
Since the log() function is defined only when its inner argument > 0, I need to specify the bounds for variables B and C to keep the entire argument positive.
However, When I try to specify the bounds in terms of the constants of the fit object, for example:
opts.Lower = [-Inf, C/min(x),…]
MATLAB gives me an error.
I know that in the main script code, the constants A, B, C, and D are not standalone variables so the main script has this issue, but as (to my knowledge) fit() finds the best values for the constants through an iterative process. Given this, It is impractical to specify a hard-coded value for the limits.
How should I approach this problem? Is there another way to find fit of a logarithmic function that incorporates ‘shifting’ and ‘stretching’ in both horizontal and vertical directions? Or is there a workaround? Thank you in advance. Hello, I am currently trying to fit experimental data that I theorize fits a logarithmic function.
To this end, I am using the fit() and fitoptions() function in order to create a logarithmic equation.
Since the default MATLAB logarithmic fit model does not seem to account for horizontal translation and scaling, I have created a custom fit type as seen below:
shiftedLog = fittype(‘A*log((B*x)-C) + D’, ‘independent’, ‘x’, ‘coefficients’, {‘A’,’B’,’C’,’D’});
% set the bounds
opts.StartPoint = […]; % Initial guesses for [A, B, C, D]
opts.Lower = […]; % Lower bounds for [A, B, C, D]
opts.Upper = […]; % Upper bounds for [A, B, C, D]
I have noticed that when I try to run this program, I have ran into errors where the fit object returns either infinity or a complex value.
Since the log() function is defined only when its inner argument > 0, I need to specify the bounds for variables B and C to keep the entire argument positive.
However, When I try to specify the bounds in terms of the constants of the fit object, for example:
opts.Lower = [-Inf, C/min(x),…]
MATLAB gives me an error.
I know that in the main script code, the constants A, B, C, and D are not standalone variables so the main script has this issue, but as (to my knowledge) fit() finds the best values for the constants through an iterative process. Given this, It is impractical to specify a hard-coded value for the limits.
How should I approach this problem? Is there another way to find fit of a logarithmic function that incorporates ‘shifting’ and ‘stretching’ in both horizontal and vertical directions? Or is there a workaround? Thank you in advance. curve fitting, function MATLAB Answers — New Questions
coefficients checked asking for him
I would like to check the coefficients of a quadratic equation as a real number. I would like to establish a vector for an equation ax^2+bx+c–> [a b c] . in case of the variable if you are a character writes zero let the felhaszáló ask for the number again with an error message.How I may make this?I would like to check the coefficients of a quadratic equation as a real number. I would like to establish a vector for an equation ax^2+bx+c–> [a b c] . in case of the variable if you are a character writes zero let the felhaszáló ask for the number again with an error message.How I may make this? I would like to check the coefficients of a quadratic equation as a real number. I would like to establish a vector for an equation ax^2+bx+c–> [a b c] . in case of the variable if you are a character writes zero let the felhaszáló ask for the number again with an error message.How I may make this? basic matlab MATLAB Answers — New Questions
How do I pass a dynamic number of output variables to a function?
Some functions change their behavior dependending on the number of output variables. For example, ndgrid will create N N-Dimensional arrays where N is the number of output variables. I need to pass a number of output variables that depends on other variable (whose value is not previously known). Is it possible to do that? What is the best way to do that?Some functions change their behavior dependending on the number of output variables. For example, ndgrid will create N N-Dimensional arrays where N is the number of output variables. I need to pass a number of output variables that depends on other variable (whose value is not previously known). Is it possible to do that? What is the best way to do that? Some functions change their behavior dependending on the number of output variables. For example, ndgrid will create N N-Dimensional arrays where N is the number of output variables. I need to pass a number of output variables that depends on other variable (whose value is not previously known). Is it possible to do that? What is the best way to do that? output, function MATLAB Answers — New Questions
How to make the font sizes of Xlabel, Ylabel, and Title different in a heat map using MATLAB?
I have used the heatmap function in MATLAB to draw a figure. However, the font sizes of Xlabel, Ylabel, and Ttile are same. How to make the font sizes of Xlabel, Ylabel, and Title different in a heat map?I have used the heatmap function in MATLAB to draw a figure. However, the font sizes of Xlabel, Ylabel, and Ttile are same. How to make the font sizes of Xlabel, Ylabel, and Title different in a heat map? I have used the heatmap function in MATLAB to draw a figure. However, the font sizes of Xlabel, Ylabel, and Ttile are same. How to make the font sizes of Xlabel, Ylabel, and Title different in a heat map? heatmap, fontsize MATLAB Answers — New Questions
How to do skull stripping when the skull in the image is not complete?
How do I remove the skull (as well as others tissues that are not tumor, but have similar intensity) from the MRI images? I have seen methods including removing the largest blob (the skull), but the skull does not enclose the brain fully in the picture I attached here. Using imbinarize will also keep other tissues which have similar intensity as the tumor in the image.
I have tried to use imerode, but the skull is not removed entirely.
Any help is appreciated. Thanks!How do I remove the skull (as well as others tissues that are not tumor, but have similar intensity) from the MRI images? I have seen methods including removing the largest blob (the skull), but the skull does not enclose the brain fully in the picture I attached here. Using imbinarize will also keep other tissues which have similar intensity as the tumor in the image.
I have tried to use imerode, but the skull is not removed entirely.
Any help is appreciated. Thanks! How do I remove the skull (as well as others tissues that are not tumor, but have similar intensity) from the MRI images? I have seen methods including removing the largest blob (the skull), but the skull does not enclose the brain fully in the picture I attached here. Using imbinarize will also keep other tissues which have similar intensity as the tumor in the image.
I have tried to use imerode, but the skull is not removed entirely.
Any help is appreciated. Thanks! brain tumor, image processing MATLAB Answers — New Questions
Create Variable in Simulink block that contains 63 elements.
I have 63 Sine blocks that will have different amplitude values. The values will be set from Matlab workspace. I would like to loop through the data and set the amplitudes values programmatically. However, I only know how to create a constant from the Create Variable option in the Simulink Sine block. How to I create a variable that has 63 elements so I can loop throught my data and assign the data correctly?I have 63 Sine blocks that will have different amplitude values. The values will be set from Matlab workspace. I would like to loop through the data and set the amplitudes values programmatically. However, I only know how to create a constant from the Create Variable option in the Simulink Sine block. How to I create a variable that has 63 elements so I can loop throught my data and assign the data correctly? I have 63 Sine blocks that will have different amplitude values. The values will be set from Matlab workspace. I would like to loop through the data and set the amplitudes values programmatically. However, I only know how to create a constant from the Create Variable option in the Simulink Sine block. How to I create a variable that has 63 elements so I can loop throught my data and assign the data correctly? create variable in simulink MATLAB Answers — New Questions
Can’t click “Roll The Dice!” problem in intro to matlab cody problems therefor cannot earn badge.
I am trying to earn my badge in intro to matlab in the Cody problems. I completed all the problems besides Roll The Dice! which is restraining me from earning the badge. It is simply not letting me click the problem.I am trying to earn my badge in intro to matlab in the Cody problems. I completed all the problems besides Roll The Dice! which is restraining me from earning the badge. It is simply not letting me click the problem. I am trying to earn my badge in intro to matlab in the Cody problems. I completed all the problems besides Roll The Dice! which is restraining me from earning the badge. It is simply not letting me click the problem. dice cody MATLAB Answers — New Questions
Applying logic to Curve Fitter Output
I am trying to use Curve Fitter and generating the code to help teach myself how to process my data without Curve Fitter.
Is there a way to apply a logic that a certain data point should be lower/higher than another certain data point, and have the coefficients adjust accordingly?
%CREATEFIT(TWOSOUSANDTQSPK,TWOSOUSANDTQAPC,TWOSOUSANDTQNM)
% Create a fit.
%
% Data for ‘2000 copy 1’ fit:
% X Input: twosousandTQSPK
% Y Input: twosousandTQAPC
% Z Output: twosousandTQnm
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 18-Jul-2024 20:43:50
%% Fit: ‘2000 copy 1’.
[xData, yData, zData] = prepareSurfaceData( twosousandTQSPK, twosousandTQAPC, twosousandTQnm );
% Set up fittype and options.
ft = fittype( ‘A+(x*B)+(C*x*x)+(y*x*D)+(y*x*x*E)+(y*F)’, ‘independent’, {‘x’, ‘y’}, ‘dependent’, ‘z’ );
opts = fitoptions( ‘Method’, ‘NonlinearLeastSquares’ );
opts.Display = ‘Off’;
opts.MaxFunEvals = 60000;
opts.MaxIter = 40000;
opts.StartPoint = [0.0526769976807926 0.737858095516997 0.269119426398556 0.422835615008808 0.547870901214845 0.942736984276934];
opts.TolFun = 0.1;
opts.TolX = 0.1;
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
% Plot fit with data.
figure( ‘Name’, ‘2000 copy 1’ );
h = plot( fitresult, [xData, yData], zData );
legend( h, ‘2000 copy 1’, ‘twosousandTQnm vs. twosousandTQSPK, twosousandTQAPC’, ‘Location’, ‘NorthEast’, ‘Interpreter’, ‘none’ );
% Label axes
xlabel( ‘twosousandTQSPK’, ‘Interpreter’, ‘none’ );
ylabel( ‘twosousandTQAPC’, ‘Interpreter’, ‘none’ );
zlabel( ‘twosousandTQnm’, ‘Interpreter’, ‘none’ );
grid off
view( -2.9, 15.3 );
I am looking to apply that the output data should follow the ‘twosousandTQSPK’ axis relative. I reserached the weighting function, but I I don’t know how I could accurately match the data inputs I have to weight it.
This is an example of what I am expecting with a different set of variables, but the results above in question should resemble this outcome to some degree.
%CREATEFIT(SIXTEENTQSPK,SIXTEENTQAPC,SIXTEENTQNM)
% Create a fit.
%
% Data for ‘1600 copy 2’ fit:
% X Input: sixteenTQSPK
% Y Input: sixteenTQAPC
% Z Output: sixteenTQnm
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 18-Jul-2024 20:55:15
%% Fit: ‘1600 copy 2’.
[xData, yData, zData] = prepareSurfaceData( sixteenTQSPK, sixteenTQAPC, sixteenTQnm );
% Set up fittype and options.
ft = fittype( ‘(y*A)+B+(x*C)+(D*x*x)+(y*x*E)+(y*x*x*F)’, ‘independent’, {‘x’, ‘y’}, ‘dependent’, ‘z’ );
opts = fitoptions( ‘Method’, ‘NonlinearLeastSquares’ );
opts.Display = ‘Off’;
opts.MaxFunEvals = 60000;
opts.MaxIter = 40000;
opts.StartPoint = [0.0430238016578078 0.168990029462704 0.649115474956452 0.73172238565867 0.647745963136307 0.450923706430945];
opts.TolFun = 0.1;
opts.TolX = 0.1;
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
% Plot fit with data.
figure( ‘Name’, ‘1600 copy 2’ );
h = plot( fitresult, [xData, yData], zData );
legend( h, ‘1600 copy 2’, ‘sixteenTQnm vs. sixteenTQSPK, sixteenTQAPC’, ‘Location’, ‘NorthEast’, ‘Interpreter’, ‘none’ );
% Label axes
xlabel( ‘sixteenTQSPK’, ‘Interpreter’, ‘none’ );
ylabel( ‘sixteenTQAPC’, ‘Interpreter’, ‘none’ );
zlabel( ‘sixteenTQnm’, ‘Interpreter’, ‘none’ );
grid off
view( -0.5, -13.0 );I am trying to use Curve Fitter and generating the code to help teach myself how to process my data without Curve Fitter.
Is there a way to apply a logic that a certain data point should be lower/higher than another certain data point, and have the coefficients adjust accordingly?
%CREATEFIT(TWOSOUSANDTQSPK,TWOSOUSANDTQAPC,TWOSOUSANDTQNM)
% Create a fit.
%
% Data for ‘2000 copy 1’ fit:
% X Input: twosousandTQSPK
% Y Input: twosousandTQAPC
% Z Output: twosousandTQnm
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 18-Jul-2024 20:43:50
%% Fit: ‘2000 copy 1’.
[xData, yData, zData] = prepareSurfaceData( twosousandTQSPK, twosousandTQAPC, twosousandTQnm );
% Set up fittype and options.
ft = fittype( ‘A+(x*B)+(C*x*x)+(y*x*D)+(y*x*x*E)+(y*F)’, ‘independent’, {‘x’, ‘y’}, ‘dependent’, ‘z’ );
opts = fitoptions( ‘Method’, ‘NonlinearLeastSquares’ );
opts.Display = ‘Off’;
opts.MaxFunEvals = 60000;
opts.MaxIter = 40000;
opts.StartPoint = [0.0526769976807926 0.737858095516997 0.269119426398556 0.422835615008808 0.547870901214845 0.942736984276934];
opts.TolFun = 0.1;
opts.TolX = 0.1;
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
% Plot fit with data.
figure( ‘Name’, ‘2000 copy 1’ );
h = plot( fitresult, [xData, yData], zData );
legend( h, ‘2000 copy 1’, ‘twosousandTQnm vs. twosousandTQSPK, twosousandTQAPC’, ‘Location’, ‘NorthEast’, ‘Interpreter’, ‘none’ );
% Label axes
xlabel( ‘twosousandTQSPK’, ‘Interpreter’, ‘none’ );
ylabel( ‘twosousandTQAPC’, ‘Interpreter’, ‘none’ );
zlabel( ‘twosousandTQnm’, ‘Interpreter’, ‘none’ );
grid off
view( -2.9, 15.3 );
I am looking to apply that the output data should follow the ‘twosousandTQSPK’ axis relative. I reserached the weighting function, but I I don’t know how I could accurately match the data inputs I have to weight it.
This is an example of what I am expecting with a different set of variables, but the results above in question should resemble this outcome to some degree.
%CREATEFIT(SIXTEENTQSPK,SIXTEENTQAPC,SIXTEENTQNM)
% Create a fit.
%
% Data for ‘1600 copy 2’ fit:
% X Input: sixteenTQSPK
% Y Input: sixteenTQAPC
% Z Output: sixteenTQnm
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 18-Jul-2024 20:55:15
%% Fit: ‘1600 copy 2’.
[xData, yData, zData] = prepareSurfaceData( sixteenTQSPK, sixteenTQAPC, sixteenTQnm );
% Set up fittype and options.
ft = fittype( ‘(y*A)+B+(x*C)+(D*x*x)+(y*x*E)+(y*x*x*F)’, ‘independent’, {‘x’, ‘y’}, ‘dependent’, ‘z’ );
opts = fitoptions( ‘Method’, ‘NonlinearLeastSquares’ );
opts.Display = ‘Off’;
opts.MaxFunEvals = 60000;
opts.MaxIter = 40000;
opts.StartPoint = [0.0430238016578078 0.168990029462704 0.649115474956452 0.73172238565867 0.647745963136307 0.450923706430945];
opts.TolFun = 0.1;
opts.TolX = 0.1;
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
% Plot fit with data.
figure( ‘Name’, ‘1600 copy 2’ );
h = plot( fitresult, [xData, yData], zData );
legend( h, ‘1600 copy 2’, ‘sixteenTQnm vs. sixteenTQSPK, sixteenTQAPC’, ‘Location’, ‘NorthEast’, ‘Interpreter’, ‘none’ );
% Label axes
xlabel( ‘sixteenTQSPK’, ‘Interpreter’, ‘none’ );
ylabel( ‘sixteenTQAPC’, ‘Interpreter’, ‘none’ );
zlabel( ‘sixteenTQnm’, ‘Interpreter’, ‘none’ );
grid off
view( -0.5, -13.0 ); I am trying to use Curve Fitter and generating the code to help teach myself how to process my data without Curve Fitter.
Is there a way to apply a logic that a certain data point should be lower/higher than another certain data point, and have the coefficients adjust accordingly?
%CREATEFIT(TWOSOUSANDTQSPK,TWOSOUSANDTQAPC,TWOSOUSANDTQNM)
% Create a fit.
%
% Data for ‘2000 copy 1’ fit:
% X Input: twosousandTQSPK
% Y Input: twosousandTQAPC
% Z Output: twosousandTQnm
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 18-Jul-2024 20:43:50
%% Fit: ‘2000 copy 1’.
[xData, yData, zData] = prepareSurfaceData( twosousandTQSPK, twosousandTQAPC, twosousandTQnm );
% Set up fittype and options.
ft = fittype( ‘A+(x*B)+(C*x*x)+(y*x*D)+(y*x*x*E)+(y*F)’, ‘independent’, {‘x’, ‘y’}, ‘dependent’, ‘z’ );
opts = fitoptions( ‘Method’, ‘NonlinearLeastSquares’ );
opts.Display = ‘Off’;
opts.MaxFunEvals = 60000;
opts.MaxIter = 40000;
opts.StartPoint = [0.0526769976807926 0.737858095516997 0.269119426398556 0.422835615008808 0.547870901214845 0.942736984276934];
opts.TolFun = 0.1;
opts.TolX = 0.1;
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
% Plot fit with data.
figure( ‘Name’, ‘2000 copy 1’ );
h = plot( fitresult, [xData, yData], zData );
legend( h, ‘2000 copy 1’, ‘twosousandTQnm vs. twosousandTQSPK, twosousandTQAPC’, ‘Location’, ‘NorthEast’, ‘Interpreter’, ‘none’ );
% Label axes
xlabel( ‘twosousandTQSPK’, ‘Interpreter’, ‘none’ );
ylabel( ‘twosousandTQAPC’, ‘Interpreter’, ‘none’ );
zlabel( ‘twosousandTQnm’, ‘Interpreter’, ‘none’ );
grid off
view( -2.9, 15.3 );
I am looking to apply that the output data should follow the ‘twosousandTQSPK’ axis relative. I reserached the weighting function, but I I don’t know how I could accurately match the data inputs I have to weight it.
This is an example of what I am expecting with a different set of variables, but the results above in question should resemble this outcome to some degree.
%CREATEFIT(SIXTEENTQSPK,SIXTEENTQAPC,SIXTEENTQNM)
% Create a fit.
%
% Data for ‘1600 copy 2’ fit:
% X Input: sixteenTQSPK
% Y Input: sixteenTQAPC
% Z Output: sixteenTQnm
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 18-Jul-2024 20:55:15
%% Fit: ‘1600 copy 2’.
[xData, yData, zData] = prepareSurfaceData( sixteenTQSPK, sixteenTQAPC, sixteenTQnm );
% Set up fittype and options.
ft = fittype( ‘(y*A)+B+(x*C)+(D*x*x)+(y*x*E)+(y*x*x*F)’, ‘independent’, {‘x’, ‘y’}, ‘dependent’, ‘z’ );
opts = fitoptions( ‘Method’, ‘NonlinearLeastSquares’ );
opts.Display = ‘Off’;
opts.MaxFunEvals = 60000;
opts.MaxIter = 40000;
opts.StartPoint = [0.0430238016578078 0.168990029462704 0.649115474956452 0.73172238565867 0.647745963136307 0.450923706430945];
opts.TolFun = 0.1;
opts.TolX = 0.1;
% Fit model to data.
[fitresult, gof] = fit( [xData, yData], zData, ft, opts );
% Plot fit with data.
figure( ‘Name’, ‘1600 copy 2’ );
h = plot( fitresult, [xData, yData], zData );
legend( h, ‘1600 copy 2’, ‘sixteenTQnm vs. sixteenTQSPK, sixteenTQAPC’, ‘Location’, ‘NorthEast’, ‘Interpreter’, ‘none’ );
% Label axes
xlabel( ‘sixteenTQSPK’, ‘Interpreter’, ‘none’ );
ylabel( ‘sixteenTQAPC’, ‘Interpreter’, ‘none’ );
zlabel( ‘sixteenTQnm’, ‘Interpreter’, ‘none’ );
grid off
view( -0.5, -13.0 ); curve fitting, curve fitter, boudaries, weighting MATLAB Answers — New Questions
Is it possible to Merge points from two accounts for same user ?
Hello ,
Suppose if a user has multiple Mathworks accounts and wants to merge both accounts. If yes, how does it work?
Is it also possible to merge answers reputation points obtained from two different Mathworks account for same user ?
Regards ,
VBBVHello ,
Suppose if a user has multiple Mathworks accounts and wants to merge both accounts. If yes, how does it work?
Is it also possible to merge answers reputation points obtained from two different Mathworks account for same user ?
Regards ,
VBBV Hello ,
Suppose if a user has multiple Mathworks accounts and wants to merge both accounts. If yes, how does it work?
Is it also possible to merge answers reputation points obtained from two different Mathworks account for same user ?
Regards ,
VBBV merge, accounts, answers, points MATLAB Answers — New Questions
1D gaussian filter for A-scans (OCT)
Hello all,
I would like to implement a gaussian filter on my A-scan (1D) from an OCT image (B-scan, 2D). The A-scan essentially represents how the intensity values fluctuate versus the depth.
I would appreciate your help.
Thank you :)Hello all,
I would like to implement a gaussian filter on my A-scan (1D) from an OCT image (B-scan, 2D). The A-scan essentially represents how the intensity values fluctuate versus the depth.
I would appreciate your help.
Thank you 🙂 Hello all,
I would like to implement a gaussian filter on my A-scan (1D) from an OCT image (B-scan, 2D). The A-scan essentially represents how the intensity values fluctuate versus the depth.
I would appreciate your help.
Thank you 🙂 1d, gauusian filter MATLAB Answers — New Questions
Did the default NumWorkers change for a local pool in R2024a?
My laptop has 14 physical cores, confirmed by feature(‘numCores’), and doing pool = parpool() starts a pool with 14 workers on R2023b. However, on R2024a on the same machine it starts a pool with only 6 workers, and feature(‘numCores’) still says there are 14 cores.
The documentation I can find still says that the default number of workers is equal to the number of physical cores. I can’t find any settings anywhere that are not set to the default values (or blank).
Is this an undocumented change in behavior? Or am I missing something?My laptop has 14 physical cores, confirmed by feature(‘numCores’), and doing pool = parpool() starts a pool with 14 workers on R2023b. However, on R2024a on the same machine it starts a pool with only 6 workers, and feature(‘numCores’) still says there are 14 cores.
The documentation I can find still says that the default number of workers is equal to the number of physical cores. I can’t find any settings anywhere that are not set to the default values (or blank).
Is this an undocumented change in behavior? Or am I missing something? My laptop has 14 physical cores, confirmed by feature(‘numCores’), and doing pool = parpool() starts a pool with 14 workers on R2023b. However, on R2024a on the same machine it starts a pool with only 6 workers, and feature(‘numCores’) still says there are 14 cores.
The documentation I can find still says that the default number of workers is equal to the number of physical cores. I can’t find any settings anywhere that are not set to the default values (or blank).
Is this an undocumented change in behavior? Or am I missing something? numworkers, physical cores MATLAB Answers — New Questions
Storing output values from a for loop into an “array”
Hello everyone,
I am trying to output the values that I get from a for loop into an "array". I am not sure how to store those "list of values" into an array
I have attached my code in reference:
Storing_Values_Into_Array.m
close all; clc;
% Value of j
j = 1i;
% For the region k_o < k_p < sqrt(u_r*e_r)*k_o
% Wavenumber in free space value = k_o
k = 2*pi;
% Permeability Value = u_r
u_r = 1;
% Permittivity Value e_r
e_r = 2.2;
% Value of kz_1
kz_1 = @(kp) sqrt((k).^2*e_r*u_r – (kp).^2);
% Value of kz_2
kz_2 = @(kp) sqrt((kp).^2 – (k).^2);
% Substrate heights = d
D = [0.02 0.04 0.06 0.08 0.10];
% Using a for loop to calculate the roots for T_M
% Solving for k_p values
for i=1:numel(D)
d=D(i);
% Equations for TM(kp)
T_M = @(kp) kz_1(kp).*sin(d.*kz_1(kp)) – e_r*kz_2(kp).*cos(d.*kz_1(kp));
kp_root=[fzero(T_M, [k , k*sqrt(e_r*u_r)])]
fplot(T_M,[k k*sqrt(e_r*u_r)], ‘LineWidth’,3); hold on
plot(kp_root,0,’o’,’MarkerSize’,8,’MarkerFaceColor’,’k’);
ylim([-5 5]);
xlim([k k*sqrt(e_r*u_r)]);
title(‘T_M vs k_p’)
ylabel(‘T_M’)
xlabel(‘k_p’)
grid on;
ax = gca;
ax.GridLineWidth = 2;
end; hold off
%{
What I am trying to do is store the values I get from "kp_root" in an
array called "kp_list" so I can use that array for calculations later on.
%}Hello everyone,
I am trying to output the values that I get from a for loop into an "array". I am not sure how to store those "list of values" into an array
I have attached my code in reference:
Storing_Values_Into_Array.m
close all; clc;
% Value of j
j = 1i;
% For the region k_o < k_p < sqrt(u_r*e_r)*k_o
% Wavenumber in free space value = k_o
k = 2*pi;
% Permeability Value = u_r
u_r = 1;
% Permittivity Value e_r
e_r = 2.2;
% Value of kz_1
kz_1 = @(kp) sqrt((k).^2*e_r*u_r – (kp).^2);
% Value of kz_2
kz_2 = @(kp) sqrt((kp).^2 – (k).^2);
% Substrate heights = d
D = [0.02 0.04 0.06 0.08 0.10];
% Using a for loop to calculate the roots for T_M
% Solving for k_p values
for i=1:numel(D)
d=D(i);
% Equations for TM(kp)
T_M = @(kp) kz_1(kp).*sin(d.*kz_1(kp)) – e_r*kz_2(kp).*cos(d.*kz_1(kp));
kp_root=[fzero(T_M, [k , k*sqrt(e_r*u_r)])]
fplot(T_M,[k k*sqrt(e_r*u_r)], ‘LineWidth’,3); hold on
plot(kp_root,0,’o’,’MarkerSize’,8,’MarkerFaceColor’,’k’);
ylim([-5 5]);
xlim([k k*sqrt(e_r*u_r)]);
title(‘T_M vs k_p’)
ylabel(‘T_M’)
xlabel(‘k_p’)
grid on;
ax = gca;
ax.GridLineWidth = 2;
end; hold off
%{
What I am trying to do is store the values I get from "kp_root" in an
array called "kp_list" so I can use that array for calculations later on.
%} Hello everyone,
I am trying to output the values that I get from a for loop into an "array". I am not sure how to store those "list of values" into an array
I have attached my code in reference:
Storing_Values_Into_Array.m
close all; clc;
% Value of j
j = 1i;
% For the region k_o < k_p < sqrt(u_r*e_r)*k_o
% Wavenumber in free space value = k_o
k = 2*pi;
% Permeability Value = u_r
u_r = 1;
% Permittivity Value e_r
e_r = 2.2;
% Value of kz_1
kz_1 = @(kp) sqrt((k).^2*e_r*u_r – (kp).^2);
% Value of kz_2
kz_2 = @(kp) sqrt((kp).^2 – (k).^2);
% Substrate heights = d
D = [0.02 0.04 0.06 0.08 0.10];
% Using a for loop to calculate the roots for T_M
% Solving for k_p values
for i=1:numel(D)
d=D(i);
% Equations for TM(kp)
T_M = @(kp) kz_1(kp).*sin(d.*kz_1(kp)) – e_r*kz_2(kp).*cos(d.*kz_1(kp));
kp_root=[fzero(T_M, [k , k*sqrt(e_r*u_r)])]
fplot(T_M,[k k*sqrt(e_r*u_r)], ‘LineWidth’,3); hold on
plot(kp_root,0,’o’,’MarkerSize’,8,’MarkerFaceColor’,’k’);
ylim([-5 5]);
xlim([k k*sqrt(e_r*u_r)]);
title(‘T_M vs k_p’)
ylabel(‘T_M’)
xlabel(‘k_p’)
grid on;
ax = gca;
ax.GridLineWidth = 2;
end; hold off
%{
What I am trying to do is store the values I get from "kp_root" in an
array called "kp_list" so I can use that array for calculations later on.
%} array, arrays, for loop MATLAB Answers — New Questions
How to Convert Entity Attribute Buses into Signal for RL Agent Observation Input?
Dear Matlab Simulink Experts,
I am having troubles with my model, right now I have designed a model to emulate a single part that goes through operations and maintenance procedures. I am utilizing bus elements in an entity generator, the next step of my model is to connect the intended output of the model from entity server ‘damage’ to an observation input port of the RL agent block. The RL agent block will then produce an output through the action port, connected again to an option of entity servers. How do I convert and entity attribute into a signal that the RL agent can receive, and vice versa, how do I revert back the signal into an entity attribute, after the RL agent has made its decision? Or what are other options other than converting entities to signal?
The attempts I have made were using a signal conversion block, and a Matlab function block, but my efforts hasn’t been rewarding so far.
Your help would be very much appreciated. Attached are my files:
ModelV1.slx (the simulink model)
BusProfile.mat (the bus elements containing the entity attribute)
initialize.m (to initialize the bus editor)
RLScriptV4.mlx (the Reinforcement Learning script)
And this is the error generated:
Thank you in advance.Dear Matlab Simulink Experts,
I am having troubles with my model, right now I have designed a model to emulate a single part that goes through operations and maintenance procedures. I am utilizing bus elements in an entity generator, the next step of my model is to connect the intended output of the model from entity server ‘damage’ to an observation input port of the RL agent block. The RL agent block will then produce an output through the action port, connected again to an option of entity servers. How do I convert and entity attribute into a signal that the RL agent can receive, and vice versa, how do I revert back the signal into an entity attribute, after the RL agent has made its decision? Or what are other options other than converting entities to signal?
The attempts I have made were using a signal conversion block, and a Matlab function block, but my efforts hasn’t been rewarding so far.
Your help would be very much appreciated. Attached are my files:
ModelV1.slx (the simulink model)
BusProfile.mat (the bus elements containing the entity attribute)
initialize.m (to initialize the bus editor)
RLScriptV4.mlx (the Reinforcement Learning script)
And this is the error generated:
Thank you in advance. Dear Matlab Simulink Experts,
I am having troubles with my model, right now I have designed a model to emulate a single part that goes through operations and maintenance procedures. I am utilizing bus elements in an entity generator, the next step of my model is to connect the intended output of the model from entity server ‘damage’ to an observation input port of the RL agent block. The RL agent block will then produce an output through the action port, connected again to an option of entity servers. How do I convert and entity attribute into a signal that the RL agent can receive, and vice versa, how do I revert back the signal into an entity attribute, after the RL agent has made its decision? Or what are other options other than converting entities to signal?
The attempts I have made were using a signal conversion block, and a Matlab function block, but my efforts hasn’t been rewarding so far.
Your help would be very much appreciated. Attached are my files:
ModelV1.slx (the simulink model)
BusProfile.mat (the bus elements containing the entity attribute)
initialize.m (to initialize the bus editor)
RLScriptV4.mlx (the Reinforcement Learning script)
And this is the error generated:
Thank you in advance. matlab, simulink, matlab function, signal, convert MATLAB Answers — New Questions
function find() sometimes doesn’t work properly
hello! i have a simple part of code, but in some cases function find doesnt work
f = [10 : 0.001 : 60];
frez = [48.7234 48.4347 46.4930 46.7682 44.9716 45.9232 48.2044 47.7394 55.0087 49.9675];
for i = 1 :length(frez)
x1 = find(f == round(frez(i)-5, 3));
x2 = find(f == round(frez(i)+5, 3));
Sd{i} = {x1 x2};
end
Sd{3}, Sd{8}, Sd{9} have 1 empty value! Why?
round(frez(3)-5, 3)
ans =
41.4930
>> find(f==ans+0.001)
ans =
31495
>> f(31494)
ans =
41.4930
But that code work!
Why ‘find’ doesnt find index even though it is?hello! i have a simple part of code, but in some cases function find doesnt work
f = [10 : 0.001 : 60];
frez = [48.7234 48.4347 46.4930 46.7682 44.9716 45.9232 48.2044 47.7394 55.0087 49.9675];
for i = 1 :length(frez)
x1 = find(f == round(frez(i)-5, 3));
x2 = find(f == round(frez(i)+5, 3));
Sd{i} = {x1 x2};
end
Sd{3}, Sd{8}, Sd{9} have 1 empty value! Why?
round(frez(3)-5, 3)
ans =
41.4930
>> find(f==ans+0.001)
ans =
31495
>> f(31494)
ans =
41.4930
But that code work!
Why ‘find’ doesnt find index even though it is? hello! i have a simple part of code, but in some cases function find doesnt work
f = [10 : 0.001 : 60];
frez = [48.7234 48.4347 46.4930 46.7682 44.9716 45.9232 48.2044 47.7394 55.0087 49.9675];
for i = 1 :length(frez)
x1 = find(f == round(frez(i)-5, 3));
x2 = find(f == round(frez(i)+5, 3));
Sd{i} = {x1 x2};
end
Sd{3}, Sd{8}, Sd{9} have 1 empty value! Why?
round(frez(3)-5, 3)
ans =
41.4930
>> find(f==ans+0.001)
ans =
31495
>> f(31494)
ans =
41.4930
But that code work!
Why ‘find’ doesnt find index even though it is? find, function, indexing, matlab code, floating point MATLAB Answers — New Questions
Save graphical objects in .mat file for later use
I have been writing matlab apps that visualize field experimental data involving movements of instrumented people and physical objects, tracking of released vapor clouds, data from referee instrumentation, and data from cfd simulations. The apps typically involve time sequenced and synchronized plotting of points and lines in uiaxes, contourf plotting of vapor concentrations, synchronized time lapsed photos or sometimes videos frame by frame. They typically wind up having between 5 and 10 axes containg plots or images which are updated with data synchronized in time on a second by second basis for a few thousand seconds.
I often need to present the visualizations to groups of people and for that I need for the app to run as quickly as it can to maintain their attention and still present the important details. I try to minimize numerical calculations in the app by pre-processing and synchronizing all the data and imagery beforehand so that the app largely involves just managing display of the graphical objects. I found that even simple graphical displays of the data (such as calls to scatter, plot, patch, contourf, etc), which I do for a few dozen sets of data every second for the thousands of seconds covered, progressively slows the real-time display as more and more data sets are involved, even with generous application of drawnows.
I have been trying to generate the displays as arrays of graphical objects and then sequence the display by adjusting object properties like visibility, alpha, etc instead of calling the scatter, plot, patch, etc functions. That allows me to control the speed of the display much better, but generating the graphical object arrays seems to be generating a delay when the app is doing it. Sorry for the long-winded description, but my question is fairly simple I think.
Instead of calling scatter at each second for all the different data streams i have been doing something like this example (the x and y here are just nominal examples of a dataset):
x = (1:50);
y = x.^1.5;
i = (1:50);
ax = axes;
xlim(ax,[0 50]);
ylim(ax,[0 360]);
hold(ax,"on");
H = arrayfun(@(i) scatter(ax,x(i),y(i),"filled","black","Visible","off"),i);
[Then I control which points are displayed when by something like the following]
for j=1:50
H(j).Visible = "on";
pause(0.05);
end
I can make points appear as a sequence of points (or other objects), or appear as a single point moving by toggling the visibility properties or alphas if needed.
Finally my question. The multiple arrayfun calls for arrays of a few thousands of elements seem to take a bit of time in the real time running of the app, but after they are done things are very fast. I think I would like to preprocess the graphical objects (eg. the H above) and then store the graphical objects in a .mat file and simply load them when the app starts up. I have been able to save them (eg H above) into a .mat file and then load them back in to the workspace, but then how do I add them to the axes that I want to add them to? For example if I try
saveobj(‘H.mat’,’H’);
Then delete H by hand with a right click (for some reason delete(H) doesn’t work at the moment), create new axes as above, how do I add the just-loaded H to the newly created axes?I have been writing matlab apps that visualize field experimental data involving movements of instrumented people and physical objects, tracking of released vapor clouds, data from referee instrumentation, and data from cfd simulations. The apps typically involve time sequenced and synchronized plotting of points and lines in uiaxes, contourf plotting of vapor concentrations, synchronized time lapsed photos or sometimes videos frame by frame. They typically wind up having between 5 and 10 axes containg plots or images which are updated with data synchronized in time on a second by second basis for a few thousand seconds.
I often need to present the visualizations to groups of people and for that I need for the app to run as quickly as it can to maintain their attention and still present the important details. I try to minimize numerical calculations in the app by pre-processing and synchronizing all the data and imagery beforehand so that the app largely involves just managing display of the graphical objects. I found that even simple graphical displays of the data (such as calls to scatter, plot, patch, contourf, etc), which I do for a few dozen sets of data every second for the thousands of seconds covered, progressively slows the real-time display as more and more data sets are involved, even with generous application of drawnows.
I have been trying to generate the displays as arrays of graphical objects and then sequence the display by adjusting object properties like visibility, alpha, etc instead of calling the scatter, plot, patch, etc functions. That allows me to control the speed of the display much better, but generating the graphical object arrays seems to be generating a delay when the app is doing it. Sorry for the long-winded description, but my question is fairly simple I think.
Instead of calling scatter at each second for all the different data streams i have been doing something like this example (the x and y here are just nominal examples of a dataset):
x = (1:50);
y = x.^1.5;
i = (1:50);
ax = axes;
xlim(ax,[0 50]);
ylim(ax,[0 360]);
hold(ax,"on");
H = arrayfun(@(i) scatter(ax,x(i),y(i),"filled","black","Visible","off"),i);
[Then I control which points are displayed when by something like the following]
for j=1:50
H(j).Visible = "on";
pause(0.05);
end
I can make points appear as a sequence of points (or other objects), or appear as a single point moving by toggling the visibility properties or alphas if needed.
Finally my question. The multiple arrayfun calls for arrays of a few thousands of elements seem to take a bit of time in the real time running of the app, but after they are done things are very fast. I think I would like to preprocess the graphical objects (eg. the H above) and then store the graphical objects in a .mat file and simply load them when the app starts up. I have been able to save them (eg H above) into a .mat file and then load them back in to the workspace, but then how do I add them to the axes that I want to add them to? For example if I try
saveobj(‘H.mat’,’H’);
Then delete H by hand with a right click (for some reason delete(H) doesn’t work at the moment), create new axes as above, how do I add the just-loaded H to the newly created axes? I have been writing matlab apps that visualize field experimental data involving movements of instrumented people and physical objects, tracking of released vapor clouds, data from referee instrumentation, and data from cfd simulations. The apps typically involve time sequenced and synchronized plotting of points and lines in uiaxes, contourf plotting of vapor concentrations, synchronized time lapsed photos or sometimes videos frame by frame. They typically wind up having between 5 and 10 axes containg plots or images which are updated with data synchronized in time on a second by second basis for a few thousand seconds.
I often need to present the visualizations to groups of people and for that I need for the app to run as quickly as it can to maintain their attention and still present the important details. I try to minimize numerical calculations in the app by pre-processing and synchronizing all the data and imagery beforehand so that the app largely involves just managing display of the graphical objects. I found that even simple graphical displays of the data (such as calls to scatter, plot, patch, contourf, etc), which I do for a few dozen sets of data every second for the thousands of seconds covered, progressively slows the real-time display as more and more data sets are involved, even with generous application of drawnows.
I have been trying to generate the displays as arrays of graphical objects and then sequence the display by adjusting object properties like visibility, alpha, etc instead of calling the scatter, plot, patch, etc functions. That allows me to control the speed of the display much better, but generating the graphical object arrays seems to be generating a delay when the app is doing it. Sorry for the long-winded description, but my question is fairly simple I think.
Instead of calling scatter at each second for all the different data streams i have been doing something like this example (the x and y here are just nominal examples of a dataset):
x = (1:50);
y = x.^1.5;
i = (1:50);
ax = axes;
xlim(ax,[0 50]);
ylim(ax,[0 360]);
hold(ax,"on");
H = arrayfun(@(i) scatter(ax,x(i),y(i),"filled","black","Visible","off"),i);
[Then I control which points are displayed when by something like the following]
for j=1:50
H(j).Visible = "on";
pause(0.05);
end
I can make points appear as a sequence of points (or other objects), or appear as a single point moving by toggling the visibility properties or alphas if needed.
Finally my question. The multiple arrayfun calls for arrays of a few thousands of elements seem to take a bit of time in the real time running of the app, but after they are done things are very fast. I think I would like to preprocess the graphical objects (eg. the H above) and then store the graphical objects in a .mat file and simply load them when the app starts up. I have been able to save them (eg H above) into a .mat file and then load them back in to the workspace, but then how do I add them to the axes that I want to add them to? For example if I try
saveobj(‘H.mat’,’H’);
Then delete H by hand with a right click (for some reason delete(H) doesn’t work at the moment), create new axes as above, how do I add the just-loaded H to the newly created axes? graphical objects, saving graphical objects MATLAB Answers — New Questions
Functions returning part of N-D data
I made a class that has methods to return specific slices of an n-d array. I can use these methods as if they are properties, and subindexing works with one exception, I can’t index with just a colon, I have to enclose it in quotes.
Here are examples where normal indexing works:
>> foobar = cfoobar(reshape(1:8,2,2,2))
foobar =
cfoobar with no properties.
>> foobar.foo([2,1],[2,1])
ans =
4 2
3 1
>> foobar.bar(1:end,end)
ans =
7
8
Here is the example that doesn’t work:
>> foobar.bar(:,end)
Input arguments to function include colon operator. To input the colon character, use ‘:’ instead.
Here is the example working with quotes:
>> foobar.bar(‘:’,end)
ans =
7
8
>>
Here is the class:
classdef cfoobar
properties (Access = private)
foobar;
end
methods
function obj = cfoobar(data)
obj.foobar = data;
end
function data = foo(obj, varargin)
data = obj.foobar(:,:,1);
data = data(varargin{:});
end
function data = bar(obj, varargin)
data = obj.foobar(:,:,2);
data = data(varargin{:});
end
end
end
How do I write the class to make the colon work by itself?I made a class that has methods to return specific slices of an n-d array. I can use these methods as if they are properties, and subindexing works with one exception, I can’t index with just a colon, I have to enclose it in quotes.
Here are examples where normal indexing works:
>> foobar = cfoobar(reshape(1:8,2,2,2))
foobar =
cfoobar with no properties.
>> foobar.foo([2,1],[2,1])
ans =
4 2
3 1
>> foobar.bar(1:end,end)
ans =
7
8
Here is the example that doesn’t work:
>> foobar.bar(:,end)
Input arguments to function include colon operator. To input the colon character, use ‘:’ instead.
Here is the example working with quotes:
>> foobar.bar(‘:’,end)
ans =
7
8
>>
Here is the class:
classdef cfoobar
properties (Access = private)
foobar;
end
methods
function obj = cfoobar(data)
obj.foobar = data;
end
function data = foo(obj, varargin)
data = obj.foobar(:,:,1);
data = data(varargin{:});
end
function data = bar(obj, varargin)
data = obj.foobar(:,:,2);
data = data(varargin{:});
end
end
end
How do I write the class to make the colon work by itself? I made a class that has methods to return specific slices of an n-d array. I can use these methods as if they are properties, and subindexing works with one exception, I can’t index with just a colon, I have to enclose it in quotes.
Here are examples where normal indexing works:
>> foobar = cfoobar(reshape(1:8,2,2,2))
foobar =
cfoobar with no properties.
>> foobar.foo([2,1],[2,1])
ans =
4 2
3 1
>> foobar.bar(1:end,end)
ans =
7
8
Here is the example that doesn’t work:
>> foobar.bar(:,end)
Input arguments to function include colon operator. To input the colon character, use ‘:’ instead.
Here is the example working with quotes:
>> foobar.bar(‘:’,end)
ans =
7
8
>>
Here is the class:
classdef cfoobar
properties (Access = private)
foobar;
end
methods
function obj = cfoobar(data)
obj.foobar = data;
end
function data = foo(obj, varargin)
data = obj.foobar(:,:,1);
data = data(varargin{:});
end
function data = bar(obj, varargin)
data = obj.foobar(:,:,2);
data = data(varargin{:});
end
end
end
How do I write the class to make the colon work by itself? indexing, class MATLAB Answers — New Questions
Where I can find the MATLAB library *.m files?
I am looking for the MATLAB library *.m files.I am looking for the MATLAB library *.m files. I am looking for the MATLAB library *.m files. library *.m files MATLAB Answers — New Questions
Simulink simulation doesn’t end
Hello, I’m simulating a Fuel Cell system with the fuel cell simscape’s block. Is a simple system, constant in input for fuel and air pressures, stoichioimetric rate for "qair" and "qfuel", in the outport "p" and "n" i connected a power sensor and then a scope connected to the latter. I use a probe to read the value of "iFC" that is a result of the simulation to input it into a MatLab Function block to calculate the rate of production of water as a function of the current generated by the cell because I need it as an output as well. The problem I encounter is that during the simulation the little loading bar stays at 0% and it appears a writing next to it that says "T = a very little number". I am fairly new to simscape that i’m using for my bachel thesis. Is there someone that knows what is happening? Thanks so much in advance, i will attach an image of the model and write the code inside the matlab function block.
code:
function H2Opr = H2O_produced(area_cell,i_cell,Ncell)
MW_H2O = 18.01528; %g/mol
F = 9.64853321233100184*10^4; %C/mol
H2Opr = (Ncell * MW_H2O * area_cell * i_cell)/(2*F);
endHello, I’m simulating a Fuel Cell system with the fuel cell simscape’s block. Is a simple system, constant in input for fuel and air pressures, stoichioimetric rate for "qair" and "qfuel", in the outport "p" and "n" i connected a power sensor and then a scope connected to the latter. I use a probe to read the value of "iFC" that is a result of the simulation to input it into a MatLab Function block to calculate the rate of production of water as a function of the current generated by the cell because I need it as an output as well. The problem I encounter is that during the simulation the little loading bar stays at 0% and it appears a writing next to it that says "T = a very little number". I am fairly new to simscape that i’m using for my bachel thesis. Is there someone that knows what is happening? Thanks so much in advance, i will attach an image of the model and write the code inside the matlab function block.
code:
function H2Opr = H2O_produced(area_cell,i_cell,Ncell)
MW_H2O = 18.01528; %g/mol
F = 9.64853321233100184*10^4; %C/mol
H2Opr = (Ncell * MW_H2O * area_cell * i_cell)/(2*F);
end Hello, I’m simulating a Fuel Cell system with the fuel cell simscape’s block. Is a simple system, constant in input for fuel and air pressures, stoichioimetric rate for "qair" and "qfuel", in the outport "p" and "n" i connected a power sensor and then a scope connected to the latter. I use a probe to read the value of "iFC" that is a result of the simulation to input it into a MatLab Function block to calculate the rate of production of water as a function of the current generated by the cell because I need it as an output as well. The problem I encounter is that during the simulation the little loading bar stays at 0% and it appears a writing next to it that says "T = a very little number". I am fairly new to simscape that i’m using for my bachel thesis. Is there someone that knows what is happening? Thanks so much in advance, i will attach an image of the model and write the code inside the matlab function block.
code:
function H2Opr = H2O_produced(area_cell,i_cell,Ncell)
MW_H2O = 18.01528; %g/mol
F = 9.64853321233100184*10^4; %C/mol
H2Opr = (Ncell * MW_H2O * area_cell * i_cell)/(2*F);
end fuel cell, simscape MATLAB Answers — New Questions
Help with matlab Butterworth filter with signal processing
Hello everyone,
I am currently using Matlab 2020 to run semg signals the matlab’s simulink to process the signal. I am on the last step and need to add a Butterworth filter I am running into error messages that I do not know how to fix. This is for live signal processing aswell. I will attach the code below and the error messages that I am recieving I would highly apperciate it if someone could fix the code and explain what they did. I am still learning how to code in Matlab. Thank you in advance
function y = fcn(u, fs)
persistent Hd;
persistent filter_initialized;
if isempty(filter_initialized)
filter_order = 5;
low_cutoff = 20;
high_cutoff = 500;
Wn = [low_cutoff high_cutoff] / (fs / 2);
[b, a] = butter(filter_order, Wn, ‘bandpass’);
[sos,g] = butter2sos(b,a);
g = sqrt(prod(Wn));
Hd = dsp.BiquadFilter(‘SOSMatrix’, sos, ‘ScaleValues’, g);
filter_initalized = true;
end
y = step(Hd, u);
end
function [sos, g] = butter2sos(b,a)
end
errors that I am getting below:
Output argument ‘sos’ is not assigned on some execution paths. Function ‘MATLAB Function1’ (#36.473.476), line 25, column 11: "sos" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Function call failed. Function ‘MATLAB Function1’ (#36.284.309), line 17, column 1: "[sos,g] = butter2sos(b,a)" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable ‘sos’. The first assignment to a local variable determines its class. Function ‘MATLAB Function1’ (#36.285.288), line 17, column 2: "sos" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable ‘g’. The first assignment to a local variable determines its class. Function ‘MATLAB Function1’ (#36.289.290), line 17, column 6: "g" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable ‘sos’. The first assignment to a local variable determines its class. Function ‘MATLAB Function1’ (#36.372.375), line 20, column 36: "sos" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Persistent variable ‘Hd’ must be assigned before it is used. The only exception is a check using ‘isempty(Hd)’ that can be performed prior to assignment. Function ‘MATLAB Function1’ (#36.450.452), line 23, column 12: "Hd" Launch diagnostic report.Hello everyone,
I am currently using Matlab 2020 to run semg signals the matlab’s simulink to process the signal. I am on the last step and need to add a Butterworth filter I am running into error messages that I do not know how to fix. This is for live signal processing aswell. I will attach the code below and the error messages that I am recieving I would highly apperciate it if someone could fix the code and explain what they did. I am still learning how to code in Matlab. Thank you in advance
function y = fcn(u, fs)
persistent Hd;
persistent filter_initialized;
if isempty(filter_initialized)
filter_order = 5;
low_cutoff = 20;
high_cutoff = 500;
Wn = [low_cutoff high_cutoff] / (fs / 2);
[b, a] = butter(filter_order, Wn, ‘bandpass’);
[sos,g] = butter2sos(b,a);
g = sqrt(prod(Wn));
Hd = dsp.BiquadFilter(‘SOSMatrix’, sos, ‘ScaleValues’, g);
filter_initalized = true;
end
y = step(Hd, u);
end
function [sos, g] = butter2sos(b,a)
end
errors that I am getting below:
Output argument ‘sos’ is not assigned on some execution paths. Function ‘MATLAB Function1’ (#36.473.476), line 25, column 11: "sos" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Function call failed. Function ‘MATLAB Function1’ (#36.284.309), line 17, column 1: "[sos,g] = butter2sos(b,a)" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable ‘sos’. The first assignment to a local variable determines its class. Function ‘MATLAB Function1’ (#36.285.288), line 17, column 2: "sos" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable ‘g’. The first assignment to a local variable determines its class. Function ‘MATLAB Function1’ (#36.289.290), line 17, column 6: "g" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable ‘sos’. The first assignment to a local variable determines its class. Function ‘MATLAB Function1’ (#36.372.375), line 20, column 36: "sos" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Persistent variable ‘Hd’ must be assigned before it is used. The only exception is a check using ‘isempty(Hd)’ that can be performed prior to assignment. Function ‘MATLAB Function1’ (#36.450.452), line 23, column 12: "Hd" Launch diagnostic report. Hello everyone,
I am currently using Matlab 2020 to run semg signals the matlab’s simulink to process the signal. I am on the last step and need to add a Butterworth filter I am running into error messages that I do not know how to fix. This is for live signal processing aswell. I will attach the code below and the error messages that I am recieving I would highly apperciate it if someone could fix the code and explain what they did. I am still learning how to code in Matlab. Thank you in advance
function y = fcn(u, fs)
persistent Hd;
persistent filter_initialized;
if isempty(filter_initialized)
filter_order = 5;
low_cutoff = 20;
high_cutoff = 500;
Wn = [low_cutoff high_cutoff] / (fs / 2);
[b, a] = butter(filter_order, Wn, ‘bandpass’);
[sos,g] = butter2sos(b,a);
g = sqrt(prod(Wn));
Hd = dsp.BiquadFilter(‘SOSMatrix’, sos, ‘ScaleValues’, g);
filter_initalized = true;
end
y = step(Hd, u);
end
function [sos, g] = butter2sos(b,a)
end
errors that I am getting below:
Output argument ‘sos’ is not assigned on some execution paths. Function ‘MATLAB Function1’ (#36.473.476), line 25, column 11: "sos" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Function call failed. Function ‘MATLAB Function1’ (#36.284.309), line 17, column 1: "[sos,g] = butter2sos(b,a)" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable ‘sos’. The first assignment to a local variable determines its class. Function ‘MATLAB Function1’ (#36.285.288), line 17, column 2: "sos" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable ‘g’. The first assignment to a local variable determines its class. Function ‘MATLAB Function1’ (#36.289.290), line 17, column 6: "g" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Undefined function or variable ‘sos’. The first assignment to a local variable determines its class. Function ‘MATLAB Function1’ (#36.372.375), line 20, column 36: "sos" Launch diagnostic report.
Component:MATLAB Function | Category:Coder error
Persistent variable ‘Hd’ must be assigned before it is used. The only exception is a check using ‘isempty(Hd)’ that can be performed prior to assignment. Function ‘MATLAB Function1’ (#36.450.452), line 23, column 12: "Hd" Launch diagnostic report. butterworth filter, matlab, simulink MATLAB Answers — New Questions