Category: Matlab
Category Archives: Matlab
is it possible to simulate ultrasonic phased parametric array in matlab ?
Can we simulate parametric array using ultrasonic transmitter transducers in matlab using phased array APP.
How we assign single transducer element directional pattern for the phased array.Could you please address how to do it.Can we simulate parametric array using ultrasonic transmitter transducers in matlab using phased array APP.
How we assign single transducer element directional pattern for the phased array.Could you please address how to do it. Can we simulate parametric array using ultrasonic transmitter transducers in matlab using phased array APP.
How we assign single transducer element directional pattern for the phased array.Could you please address how to do it. parametric array, phased array MATLAB Answers — New Questions
How to calculate right parameters for 3-phase two winding transformer Simscape Block?
Hi. I have issues with understanding and using parameters for a 3-phase two winding power transformer Simscape Block.
Three-phase linear nonideal wye- and delta-configurable two-winding transformer with saturation capability – MATLAB (mathworks.com)
I need to simulate the voltage drop and transformer power losses in a system with a 3-phase two winding transformer. I have transformer parameters from it’s datasheet, such as rated power, rated primary and secondary voltages, rated currents. For estimation of impedances I have a short-circuit voltage, short-circuit power, no-load losses. From these I can calcualte winding impedances R1, R2, L1,L2. shunt magnetizing impedances Rm, Lm.
The problem is that I don’t know where and how to provide these parameter in Simscape block. The impedances in the block are in power and not clear which applies to what. Does enyone have more clear description of block parameters and their relativity to phisical parameters?Hi. I have issues with understanding and using parameters for a 3-phase two winding power transformer Simscape Block.
Three-phase linear nonideal wye- and delta-configurable two-winding transformer with saturation capability – MATLAB (mathworks.com)
I need to simulate the voltage drop and transformer power losses in a system with a 3-phase two winding transformer. I have transformer parameters from it’s datasheet, such as rated power, rated primary and secondary voltages, rated currents. For estimation of impedances I have a short-circuit voltage, short-circuit power, no-load losses. From these I can calcualte winding impedances R1, R2, L1,L2. shunt magnetizing impedances Rm, Lm.
The problem is that I don’t know where and how to provide these parameter in Simscape block. The impedances in the block are in power and not clear which applies to what. Does enyone have more clear description of block parameters and their relativity to phisical parameters? Hi. I have issues with understanding and using parameters for a 3-phase two winding power transformer Simscape Block.
Three-phase linear nonideal wye- and delta-configurable two-winding transformer with saturation capability – MATLAB (mathworks.com)
I need to simulate the voltage drop and transformer power losses in a system with a 3-phase two winding transformer. I have transformer parameters from it’s datasheet, such as rated power, rated primary and secondary voltages, rated currents. For estimation of impedances I have a short-circuit voltage, short-circuit power, no-load losses. From these I can calcualte winding impedances R1, R2, L1,L2. shunt magnetizing impedances Rm, Lm.
The problem is that I don’t know where and how to provide these parameter in Simscape block. The impedances in the block are in power and not clear which applies to what. Does enyone have more clear description of block parameters and their relativity to phisical parameters? transformer, simscape, 3-phase MATLAB Answers — New Questions
Plotting an image in a geospatial domain given Lat and Lon information
Dear all,
After trying everything and more, it is time to give up and ask for your help.
I do have a matrix of Lat values, a matrix of Lon values, and a matrix of actual data. I need to display this in a geospatial domain, overlaying a Shapefile. Additionally, it is essential for me to add a scale bar. I have tried, geoshow, goeplot, mapshow, worldmap, and probably something else too, but every time there is something that goes wrong (i.e., Adding GeographicAxes to axes is not supported, etc.).
The best I achieved was:
close all
clc
figure
geoshow(LAT, LON, DATA, ‘DisplayType’, ‘texturemap’);
mapshow(SHP, ‘FaceColor’, ‘none’, ‘EdgeColor’, ‘black’, ‘LineWidth’, 1.5);
colormap gray
The problem with the code above is that nothing is georeferenced and, as such, it is impossible for me to add a scale bar.
Could you please help me make a nice georeferenced map?
Any help would be greatly appreciated.
I have attached the LAT, LON, DATA, and SHP.
Thanks a lot in advanceDear all,
After trying everything and more, it is time to give up and ask for your help.
I do have a matrix of Lat values, a matrix of Lon values, and a matrix of actual data. I need to display this in a geospatial domain, overlaying a Shapefile. Additionally, it is essential for me to add a scale bar. I have tried, geoshow, goeplot, mapshow, worldmap, and probably something else too, but every time there is something that goes wrong (i.e., Adding GeographicAxes to axes is not supported, etc.).
The best I achieved was:
close all
clc
figure
geoshow(LAT, LON, DATA, ‘DisplayType’, ‘texturemap’);
mapshow(SHP, ‘FaceColor’, ‘none’, ‘EdgeColor’, ‘black’, ‘LineWidth’, 1.5);
colormap gray
The problem with the code above is that nothing is georeferenced and, as such, it is impossible for me to add a scale bar.
Could you please help me make a nice georeferenced map?
Any help would be greatly appreciated.
I have attached the LAT, LON, DATA, and SHP.
Thanks a lot in advance Dear all,
After trying everything and more, it is time to give up and ask for your help.
I do have a matrix of Lat values, a matrix of Lon values, and a matrix of actual data. I need to display this in a geospatial domain, overlaying a Shapefile. Additionally, it is essential for me to add a scale bar. I have tried, geoshow, goeplot, mapshow, worldmap, and probably something else too, but every time there is something that goes wrong (i.e., Adding GeographicAxes to axes is not supported, etc.).
The best I achieved was:
close all
clc
figure
geoshow(LAT, LON, DATA, ‘DisplayType’, ‘texturemap’);
mapshow(SHP, ‘FaceColor’, ‘none’, ‘EdgeColor’, ‘black’, ‘LineWidth’, 1.5);
colormap gray
The problem with the code above is that nothing is georeferenced and, as such, it is impossible for me to add a scale bar.
Could you please help me make a nice georeferenced map?
Any help would be greatly appreciated.
I have attached the LAT, LON, DATA, and SHP.
Thanks a lot in advance plot, geoplot, image, image analysis, image processing, geospatial, georeference, latitude, longitude MATLAB Answers — New Questions
Simulink Code inspector – Customize the header file search path
When I try to generate the Simulink Code inspector report, its defaulting to a mathdef.h located in the polyspaceveroiifiercxxinclude location. Is it possible to customize the code inspector to ignore the includes from the polyspace include location and use project specific location?When I try to generate the Simulink Code inspector report, its defaulting to a mathdef.h located in the polyspaceveroiifiercxxinclude location. Is it possible to customize the code inspector to ignore the includes from the polyspace include location and use project specific location? When I try to generate the Simulink Code inspector report, its defaulting to a mathdef.h located in the polyspaceveroiifiercxxinclude location. Is it possible to customize the code inspector to ignore the includes from the polyspace include location and use project specific location? simulink code inspector MATLAB Answers — New Questions
Client installation package for Mathlab
Hi all,
I’m looking for a way to create a "universal" installation package for Matlab.
Our users will not have local admin and due to security policies the software is installed by packages.
However im under the impression that there is no generic software install and that all specific features require a specific installation procedure.
Can you tell me if there is a way to achieve this? Or is it an option to use the webbased version somehow?
Any help is welcome.
Regards,Hi all,
I’m looking for a way to create a "universal" installation package for Matlab.
Our users will not have local admin and due to security policies the software is installed by packages.
However im under the impression that there is no generic software install and that all specific features require a specific installation procedure.
Can you tell me if there is a way to achieve this? Or is it an option to use the webbased version somehow?
Any help is welcome.
Regards, Hi all,
I’m looking for a way to create a "universal" installation package for Matlab.
Our users will not have local admin and due to security policies the software is installed by packages.
However im under the impression that there is no generic software install and that all specific features require a specific installation procedure.
Can you tell me if there is a way to achieve this? Or is it an option to use the webbased version somehow?
Any help is welcome.
Regards, mathlab installation package MATLAB Answers — New Questions
How do I add shapes to my Simulink model
I want to add a dotted line to add clarity to my model. In addition, I want to add a box to show future addition.
I do I add static shapes and figures (rectangle) to my model?I want to add a dotted line to add clarity to my model. In addition, I want to add a box to show future addition.
I do I add static shapes and figures (rectangle) to my model? I want to add a dotted line to add clarity to my model. In addition, I want to add a box to show future addition.
I do I add static shapes and figures (rectangle) to my model? static shapes MATLAB Answers — New Questions
Complex matlab script migration into simulink
I’m currently working with a rather length Matlab script, and am trying to move it onto simulink to adopt a more ‘drag n drop’ logic flow, as in Simulink we are able to use both custom function blocks as well as default lib blocks. After trying to move this script to Simulink I realized that I have been running into a lot of code generation incompatibility errors, I’d like to ask whether I can "pull" a plot from the base Matlab workspace into Simulink when I run a Simulink function?
Say that I click on a specific block on Simulink that triggers a script in the base workspace to run, and then the results and plots from the base workspace script are "sent" to Simulink.
Is this achievable?
Thanks!I’m currently working with a rather length Matlab script, and am trying to move it onto simulink to adopt a more ‘drag n drop’ logic flow, as in Simulink we are able to use both custom function blocks as well as default lib blocks. After trying to move this script to Simulink I realized that I have been running into a lot of code generation incompatibility errors, I’d like to ask whether I can "pull" a plot from the base Matlab workspace into Simulink when I run a Simulink function?
Say that I click on a specific block on Simulink that triggers a script in the base workspace to run, and then the results and plots from the base workspace script are "sent" to Simulink.
Is this achievable?
Thanks! I’m currently working with a rather length Matlab script, and am trying to move it onto simulink to adopt a more ‘drag n drop’ logic flow, as in Simulink we are able to use both custom function blocks as well as default lib blocks. After trying to move this script to Simulink I realized that I have been running into a lot of code generation incompatibility errors, I’d like to ask whether I can "pull" a plot from the base Matlab workspace into Simulink when I run a Simulink function?
Say that I click on a specific block on Simulink that triggers a script in the base workspace to run, and then the results and plots from the base workspace script are "sent" to Simulink.
Is this achievable?
Thanks! simulink, matlab code, code generation MATLAB Answers — New Questions
Keyboard remapping in live editor not working.
Hi guys,
I’m on a mac here and have remapped the begin and end keys to "begin line" and "end line" in matlab.
I have also removed these keys from "begin doc" and "end doc".
This works perfectly in the main editor and command windows but is totally ignored in the live editor where the original "begin doc" and "end doc" are still mapped to the keys.
Am I doing something wrong or is this a bug?
Thanks for any help
AndyHi guys,
I’m on a mac here and have remapped the begin and end keys to "begin line" and "end line" in matlab.
I have also removed these keys from "begin doc" and "end doc".
This works perfectly in the main editor and command windows but is totally ignored in the live editor where the original "begin doc" and "end doc" are still mapped to the keys.
Am I doing something wrong or is this a bug?
Thanks for any help
Andy Hi guys,
I’m on a mac here and have remapped the begin and end keys to "begin line" and "end line" in matlab.
I have also removed these keys from "begin doc" and "end doc".
This works perfectly in the main editor and command windows but is totally ignored in the live editor where the original "begin doc" and "end doc" are still mapped to the keys.
Am I doing something wrong or is this a bug?
Thanks for any help
Andy live editor, keyboard remapping MATLAB Answers — New Questions
optimization expression includes an integration
I am trying an optimization problem in which the expression of the objective function includes an integral.
It is obvious that the sigma equal to one results in the optimium solution. I want to use the optimization toolbox to get this result with an initial sigma equal to, say, 10.
I wrote the following code.
g1 = @(x,c) (exp(-(0.5*(x./c).^2))./sqrt(2*pi*c^2));
c = optimvar("c",1,1,’Type’,’continuous’,’LowerBound’,0.1,’UpperBound’,10);
prob = optimproblem(‘Objective’, (0.5 – integral(@(x)g1(x,c),0, 10)).^2);
[solf,fvalf,eflagf,outputf] = solve(prob)
The following error is generated.
Error using integralCalc>finalInputChecks (line 544)
Input function must return ‘double’ or ‘single’ values. Found
‘optim.problemdef.OptimizationExpression’.
I have two questions:
1, Am I coding the problem properly/correctly?
2, If the code is basically correct, how can I solve the error?
Thank you.I am trying an optimization problem in which the expression of the objective function includes an integral.
It is obvious that the sigma equal to one results in the optimium solution. I want to use the optimization toolbox to get this result with an initial sigma equal to, say, 10.
I wrote the following code.
g1 = @(x,c) (exp(-(0.5*(x./c).^2))./sqrt(2*pi*c^2));
c = optimvar("c",1,1,’Type’,’continuous’,’LowerBound’,0.1,’UpperBound’,10);
prob = optimproblem(‘Objective’, (0.5 – integral(@(x)g1(x,c),0, 10)).^2);
[solf,fvalf,eflagf,outputf] = solve(prob)
The following error is generated.
Error using integralCalc>finalInputChecks (line 544)
Input function must return ‘double’ or ‘single’ values. Found
‘optim.problemdef.OptimizationExpression’.
I have two questions:
1, Am I coding the problem properly/correctly?
2, If the code is basically correct, how can I solve the error?
Thank you. I am trying an optimization problem in which the expression of the objective function includes an integral.
It is obvious that the sigma equal to one results in the optimium solution. I want to use the optimization toolbox to get this result with an initial sigma equal to, say, 10.
I wrote the following code.
g1 = @(x,c) (exp(-(0.5*(x./c).^2))./sqrt(2*pi*c^2));
c = optimvar("c",1,1,’Type’,’continuous’,’LowerBound’,0.1,’UpperBound’,10);
prob = optimproblem(‘Objective’, (0.5 – integral(@(x)g1(x,c),0, 10)).^2);
[solf,fvalf,eflagf,outputf] = solve(prob)
The following error is generated.
Error using integralCalc>finalInputChecks (line 544)
Input function must return ‘double’ or ‘single’ values. Found
‘optim.problemdef.OptimizationExpression’.
I have two questions:
1, Am I coding the problem properly/correctly?
2, If the code is basically correct, how can I solve the error?
Thank you. #optimization #integral MATLAB Answers — New Questions
How to Graph integrals?
Hello everybody,
I have a little trouble here. I’m trying to graph the following auction at first price:
syms x a
gamma = 0.3;
b_hat= 0.542;
fun = b/2;
F(a) = int(fun, x, 0, a);
fplot(F,[0 1])
But I still can’t get it, I would appreciate it if you could help me.Hello everybody,
I have a little trouble here. I’m trying to graph the following auction at first price:
syms x a
gamma = 0.3;
b_hat= 0.542;
fun = b/2;
F(a) = int(fun, x, 0, a);
fplot(F,[0 1])
But I still can’t get it, I would appreciate it if you could help me. Hello everybody,
I have a little trouble here. I’m trying to graph the following auction at first price:
syms x a
gamma = 0.3;
b_hat= 0.542;
fun = b/2;
F(a) = int(fun, x, 0, a);
fplot(F,[0 1])
But I still can’t get it, I would appreciate it if you could help me. graph, integrals MATLAB Answers — New Questions
Connecting Xbox Controller to Simulink Real-Time
Hi,
Im trying to add a xbox controller to my simulink Real-Time. However the only blocks I could find and use only work for normal simulink. I tried using Gamepad Simulator block and the Joystick Input block and I tested and worked only for normal Simulink. When I try to use them in Simulink Real-Time, it doesnt take the values. When I use the the JoyStick input block in simulink real-time, it gives me an error and says "Error:Unable to find S-function module ‘joyinput’. S-function modules must exist as either source files or pre-compiled object files on the MATLAB path.".
Is there a way to get around this?
ThanksHi,
Im trying to add a xbox controller to my simulink Real-Time. However the only blocks I could find and use only work for normal simulink. I tried using Gamepad Simulator block and the Joystick Input block and I tested and worked only for normal Simulink. When I try to use them in Simulink Real-Time, it doesnt take the values. When I use the the JoyStick input block in simulink real-time, it gives me an error and says "Error:Unable to find S-function module ‘joyinput’. S-function modules must exist as either source files or pre-compiled object files on the MATLAB path.".
Is there a way to get around this?
Thanks Hi,
Im trying to add a xbox controller to my simulink Real-Time. However the only blocks I could find and use only work for normal simulink. I tried using Gamepad Simulator block and the Joystick Input block and I tested and worked only for normal Simulink. When I try to use them in Simulink Real-Time, it doesnt take the values. When I use the the JoyStick input block in simulink real-time, it gives me an error and says "Error:Unable to find S-function module ‘joyinput’. S-function modules must exist as either source files or pre-compiled object files on the MATLAB path.".
Is there a way to get around this?
Thanks simulink, simulink realtime MATLAB Answers — New Questions
contour plot problem Z must be at least a 2×2 matrix
Hallo everyone,
i have a problem to make the contour plot, it always shows Z must be at least a 2×2 matrix. i have try my best to solve, but it still not work, could you please to help me? The code is as follows.
x=[80;100;90;90;90]
y=[4;4;2;6;4]
[X,Y] = meshgrid(x,y)
% Polly 11 f(x,y)=p00+p10*x+p01*y
f1=1.7419-0.0006*x+0.0132*y
contour(X,Y,f1)
Thanks and best regards
JLHallo everyone,
i have a problem to make the contour plot, it always shows Z must be at least a 2×2 matrix. i have try my best to solve, but it still not work, could you please to help me? The code is as follows.
x=[80;100;90;90;90]
y=[4;4;2;6;4]
[X,Y] = meshgrid(x,y)
% Polly 11 f(x,y)=p00+p10*x+p01*y
f1=1.7419-0.0006*x+0.0132*y
contour(X,Y,f1)
Thanks and best regards
JL Hallo everyone,
i have a problem to make the contour plot, it always shows Z must be at least a 2×2 matrix. i have try my best to solve, but it still not work, could you please to help me? The code is as follows.
x=[80;100;90;90;90]
y=[4;4;2;6;4]
[X,Y] = meshgrid(x,y)
% Polly 11 f(x,y)=p00+p10*x+p01*y
f1=1.7419-0.0006*x+0.0132*y
contour(X,Y,f1)
Thanks and best regards
JL contour MATLAB Answers — New Questions
Simulink bandpass filter live signaling
Hello everyone,
I am currently working in Matlab’s simulink to filter live SEMG signaling. I have created an application pathway, with a RMS filter, and normilization, right now I am not fully understanding how to create a Bandpass filter. I have a buffer of 5 and I am trying to have an ouput of 1.
Could anyone explain the dimesions I should implement in the Frequency specifications. Thank you in advancedHello everyone,
I am currently working in Matlab’s simulink to filter live SEMG signaling. I have created an application pathway, with a RMS filter, and normilization, right now I am not fully understanding how to create a Bandpass filter. I have a buffer of 5 and I am trying to have an ouput of 1.
Could anyone explain the dimesions I should implement in the Frequency specifications. Thank you in advanced Hello everyone,
I am currently working in Matlab’s simulink to filter live SEMG signaling. I have created an application pathway, with a RMS filter, and normilization, right now I am not fully understanding how to create a Bandpass filter. I have a buffer of 5 and I am trying to have an ouput of 1.
Could anyone explain the dimesions I should implement in the Frequency specifications. Thank you in advanced simulink, bandpassfilter MATLAB Answers — New Questions
How to import KNN-model structure from matlab into simulink
All,
The problem I am facing is a move of KNN-model data structure from matlab to simulink in a loop:
In matlab TrainingData is used as input to create an KNN based-model. In simulink, at some point, I want to use this model to predict the outcome of a certain decision based on certain parameters that evolve during simulation. If the simulation ends, the outcome of the decsion is used in matlab to adjust the TrainingData and to update the KNN-model. The updated KNN-model will be used for the next simutlation.
Note that before the loop starts, the feature table exists.
Note that in matlab, the knn-model data is the outcome of the command: knnmodel = fitcknn(TrainingData, ‘feature’). So i need to import this knnmodel structure into simulink.
My problem is that I do not see how to successfully import such KNN-model into the simulink model for decision making (prediction).
Is there any method to get this done?All,
The problem I am facing is a move of KNN-model data structure from matlab to simulink in a loop:
In matlab TrainingData is used as input to create an KNN based-model. In simulink, at some point, I want to use this model to predict the outcome of a certain decision based on certain parameters that evolve during simulation. If the simulation ends, the outcome of the decsion is used in matlab to adjust the TrainingData and to update the KNN-model. The updated KNN-model will be used for the next simutlation.
Note that before the loop starts, the feature table exists.
Note that in matlab, the knn-model data is the outcome of the command: knnmodel = fitcknn(TrainingData, ‘feature’). So i need to import this knnmodel structure into simulink.
My problem is that I do not see how to successfully import such KNN-model into the simulink model for decision making (prediction).
Is there any method to get this done? All,
The problem I am facing is a move of KNN-model data structure from matlab to simulink in a loop:
In matlab TrainingData is used as input to create an KNN based-model. In simulink, at some point, I want to use this model to predict the outcome of a certain decision based on certain parameters that evolve during simulation. If the simulation ends, the outcome of the decsion is used in matlab to adjust the TrainingData and to update the KNN-model. The updated KNN-model will be used for the next simutlation.
Note that before the loop starts, the feature table exists.
Note that in matlab, the knn-model data is the outcome of the command: knnmodel = fitcknn(TrainingData, ‘feature’). So i need to import this knnmodel structure into simulink.
My problem is that I do not see how to successfully import such KNN-model into the simulink model for decision making (prediction).
Is there any method to get this done? machine learning, matlab, simulink MATLAB Answers — New Questions
Can I download previous releases of MATLAB?
Can I download previous releases of MATLAB?Can I download previous releases of MATLAB? Can I download previous releases of MATLAB? MATLAB Answers — New Questions
Formatting input data for linear regression model in leave-out-one validation testing
Hello there I have data from 10 trials stored in a 10×1 cell (Predictors) and the corespoding respose vairables stored in a 10×1 cell (Response). I am trying to trian a simple linear regression model and make predictions by leaving one trial out and using the other 9 trials to train the linear regression model and the one to predict/test the model by producing RMSE values. I am unsure of how to format my input within the "fitlm" function as I keep getting the follwing error:
% Train the network
for i = 1:length(Predictors) %iterate over all data points
validationdataX = Predictors(i);
validationdataY = Response(i);
%Exclude the current index (i) for training
trainingIndices = setdiff(1:length(Predictors),i);
traningdataX = Predictors(trainingIndices)
trainingdataY = Response(trainingIndices)
net = fitlm(traningdataX,trainingdataY)
ypred = predict(net,validationdataX);
TrueVal = validationdataY;
TrueValue = cell2mat(TrueVal);
Predvalue = {Predval};
PredictedValue = cell2mat(Predvalue);
RMSE = rmse(PredictedValue,TrueValue)
end
Error using classreg.regr.TermsRegression/handleDataArgs (line 589)
Predictor variables must be numeric vectors, numeric matrices, or categorical vectors.
Error in LinearModel.fit (line 1000)
[X,y,haveDataset,otherArgs] = LinearModel.handleDataArgs(X,paramNames,varargin{:});
Error in fitlm (line 134)
model = LinearModel.fit(X,varargin{:});
Any suggestions on how to fix this and to get the model to work correcly and make predictions using leave out one validation approach would be greatly appreciated!Hello there I have data from 10 trials stored in a 10×1 cell (Predictors) and the corespoding respose vairables stored in a 10×1 cell (Response). I am trying to trian a simple linear regression model and make predictions by leaving one trial out and using the other 9 trials to train the linear regression model and the one to predict/test the model by producing RMSE values. I am unsure of how to format my input within the "fitlm" function as I keep getting the follwing error:
% Train the network
for i = 1:length(Predictors) %iterate over all data points
validationdataX = Predictors(i);
validationdataY = Response(i);
%Exclude the current index (i) for training
trainingIndices = setdiff(1:length(Predictors),i);
traningdataX = Predictors(trainingIndices)
trainingdataY = Response(trainingIndices)
net = fitlm(traningdataX,trainingdataY)
ypred = predict(net,validationdataX);
TrueVal = validationdataY;
TrueValue = cell2mat(TrueVal);
Predvalue = {Predval};
PredictedValue = cell2mat(Predvalue);
RMSE = rmse(PredictedValue,TrueValue)
end
Error using classreg.regr.TermsRegression/handleDataArgs (line 589)
Predictor variables must be numeric vectors, numeric matrices, or categorical vectors.
Error in LinearModel.fit (line 1000)
[X,y,haveDataset,otherArgs] = LinearModel.handleDataArgs(X,paramNames,varargin{:});
Error in fitlm (line 134)
model = LinearModel.fit(X,varargin{:});
Any suggestions on how to fix this and to get the model to work correcly and make predictions using leave out one validation approach would be greatly appreciated! Hello there I have data from 10 trials stored in a 10×1 cell (Predictors) and the corespoding respose vairables stored in a 10×1 cell (Response). I am trying to trian a simple linear regression model and make predictions by leaving one trial out and using the other 9 trials to train the linear regression model and the one to predict/test the model by producing RMSE values. I am unsure of how to format my input within the "fitlm" function as I keep getting the follwing error:
% Train the network
for i = 1:length(Predictors) %iterate over all data points
validationdataX = Predictors(i);
validationdataY = Response(i);
%Exclude the current index (i) for training
trainingIndices = setdiff(1:length(Predictors),i);
traningdataX = Predictors(trainingIndices)
trainingdataY = Response(trainingIndices)
net = fitlm(traningdataX,trainingdataY)
ypred = predict(net,validationdataX);
TrueVal = validationdataY;
TrueValue = cell2mat(TrueVal);
Predvalue = {Predval};
PredictedValue = cell2mat(Predvalue);
RMSE = rmse(PredictedValue,TrueValue)
end
Error using classreg.regr.TermsRegression/handleDataArgs (line 589)
Predictor variables must be numeric vectors, numeric matrices, or categorical vectors.
Error in LinearModel.fit (line 1000)
[X,y,haveDataset,otherArgs] = LinearModel.handleDataArgs(X,paramNames,varargin{:});
Error in fitlm (line 134)
model = LinearModel.fit(X,varargin{:});
Any suggestions on how to fix this and to get the model to work correcly and make predictions using leave out one validation approach would be greatly appreciated! linear regression, input data formatting, validation MATLAB Answers — New Questions
How can I clear an error “The expression to the left of the equals sign is not a valid target for an assignment?”
I tried to solve a problem (see the attachments). But I gor an error "The expression to the left of the equals sign is not a valid target for an assignment". How to solve this issue.I tried to solve a problem (see the attachments). But I gor an error "The expression to the left of the equals sign is not a valid target for an assignment". How to solve this issue. I tried to solve a problem (see the attachments). But I gor an error "The expression to the left of the equals sign is not a valid target for an assignment". How to solve this issue. bvp4c MATLAB Answers — New Questions
How can i fit the inscribed circle with different diameter in an image ??
I have an image which has the close shape. I need to fill the the close loop with different diameter in the image. Can anyone give the suggestion for that ??I have an image which has the close shape. I need to fill the the close loop with different diameter in the image. Can anyone give the suggestion for that ?? I have an image which has the close shape. I need to fill the the close loop with different diameter in the image. Can anyone give the suggestion for that ?? fill, prescribed circle, image processing MATLAB Answers — New Questions
Adding standard deviation as a bar to a scatter plot
Hello all, I’m plotting weather data and want to show the mean, standard deviation and min-max values in one plot. I’ve attached a photo of the ideal end result. How might I go about it using the data below as an example?
Mean_Temp_1 = [12]
Mean_Temp_2 = [15]
Mean_Temp_3 = [11]
SD_1 = [1.2]
SD_2 = [0.8]
SD_3 = [1.4]
Max_1 = [14]
Max_2 = [17]
Max_3 = [12]
Min_1 = [10]
Min_2 = [12]
Min_3 = [10]Hello all, I’m plotting weather data and want to show the mean, standard deviation and min-max values in one plot. I’ve attached a photo of the ideal end result. How might I go about it using the data below as an example?
Mean_Temp_1 = [12]
Mean_Temp_2 = [15]
Mean_Temp_3 = [11]
SD_1 = [1.2]
SD_2 = [0.8]
SD_3 = [1.4]
Max_1 = [14]
Max_2 = [17]
Max_3 = [12]
Min_1 = [10]
Min_2 = [12]
Min_3 = [10] Hello all, I’m plotting weather data and want to show the mean, standard deviation and min-max values in one plot. I’ve attached a photo of the ideal end result. How might I go about it using the data below as an example?
Mean_Temp_1 = [12]
Mean_Temp_2 = [15]
Mean_Temp_3 = [11]
SD_1 = [1.2]
SD_2 = [0.8]
SD_3 = [1.4]
Max_1 = [14]
Max_2 = [17]
Max_3 = [12]
Min_1 = [10]
Min_2 = [12]
Min_3 = [10] scatter MATLAB Answers — New Questions
Curve Fitting complex data (x,y) for constant extraction.
Hello,
I’ve been following the following link — https://www.mathworks.com/help/optim/ug/fit-model-to-complex-data.html#
to try and extract the real constants (N_s,Tau_s, and c) from the Drude-Smith derivation for complex conductivity. This involves fitting both the real and imaginary components (which may be the problem in itself, since the example fits regular data with complex noise?)
I’ve attempted both lsqnonlin and lsqcurve fit methods.
file =[‘DSfit_Sitest.xls’]; %%file attached
input = xlsread(file);
x = input(:,1); %%%% xdata, freqency, omega, real numbers from (0.2-1.4 THz)
R = input(:,2); %%%% Real component (blue in plot)
I = input(:,3);%%%% Imaginary component (orange in plot)
ydata = complex(R,I); %%%% complex conductivity, sigma_s
q = 1.602E-19; %% charge
m = 0.98; %% effective electron mass
mi = 1/0.98; %% inverse electron mass used to make typing the equation simpler
objfcn = @(C)(((C(1)*(q^2)*mi*C(2))./(1-1i.*x.*C(2))).*(1+(C(3)./(1-1i.*x.*C(2))))) – ydata;
opts = optimoptions(@lsqnonlin,’Display’,’off’);
x0=[1e17, 100, -0.1]; %% initial guesses, I expect these to be reasonable values
LB = [1e15, 1, -1]; %%Typical carrier concentrations (cm-3), Tau_s (C(2)) units in picoseconds, -1<c<0
UB = [1e21, 1000, 0];
[const,~,residual,exitflag,output] = lsqnonlin(objfcn,x0,[],[],opts); %% does not run with LB and UB, so i leave blank.
This method outputs the initial guesses, and when I use the initial guesses to plot the outputs I get my data graph flipped, meaning my function just equals zero.
Using lsqcurvefit
objfcn = @(C,x)(((C(1)*(q^2).*mi.*C(2))./(1-1i.*x.*C(2))).*(1+(C(3)./(1-1i.*x.*C(2)))));
opts = optimoptions(@lsqcurvefit,opts);
x0=[1e17, 100, -0.1];
LB = [1e15, 1, -1];
UB = [1e21, 1e3, 0];
[constan,resnorm] = lsqcurvefit(objfcn,x0,x,ydata,[],[],opts)
I get the error "not enough input arguments" in my objfcn, and it still outputs the initial guesses
Any help with why this isnt working or if im doing something really wrong is greatly appreciated! I am a novice Matlab user.
Thank you!!Hello,
I’ve been following the following link — https://www.mathworks.com/help/optim/ug/fit-model-to-complex-data.html#
to try and extract the real constants (N_s,Tau_s, and c) from the Drude-Smith derivation for complex conductivity. This involves fitting both the real and imaginary components (which may be the problem in itself, since the example fits regular data with complex noise?)
I’ve attempted both lsqnonlin and lsqcurve fit methods.
file =[‘DSfit_Sitest.xls’]; %%file attached
input = xlsread(file);
x = input(:,1); %%%% xdata, freqency, omega, real numbers from (0.2-1.4 THz)
R = input(:,2); %%%% Real component (blue in plot)
I = input(:,3);%%%% Imaginary component (orange in plot)
ydata = complex(R,I); %%%% complex conductivity, sigma_s
q = 1.602E-19; %% charge
m = 0.98; %% effective electron mass
mi = 1/0.98; %% inverse electron mass used to make typing the equation simpler
objfcn = @(C)(((C(1)*(q^2)*mi*C(2))./(1-1i.*x.*C(2))).*(1+(C(3)./(1-1i.*x.*C(2))))) – ydata;
opts = optimoptions(@lsqnonlin,’Display’,’off’);
x0=[1e17, 100, -0.1]; %% initial guesses, I expect these to be reasonable values
LB = [1e15, 1, -1]; %%Typical carrier concentrations (cm-3), Tau_s (C(2)) units in picoseconds, -1<c<0
UB = [1e21, 1000, 0];
[const,~,residual,exitflag,output] = lsqnonlin(objfcn,x0,[],[],opts); %% does not run with LB and UB, so i leave blank.
This method outputs the initial guesses, and when I use the initial guesses to plot the outputs I get my data graph flipped, meaning my function just equals zero.
Using lsqcurvefit
objfcn = @(C,x)(((C(1)*(q^2).*mi.*C(2))./(1-1i.*x.*C(2))).*(1+(C(3)./(1-1i.*x.*C(2)))));
opts = optimoptions(@lsqcurvefit,opts);
x0=[1e17, 100, -0.1];
LB = [1e15, 1, -1];
UB = [1e21, 1e3, 0];
[constan,resnorm] = lsqcurvefit(objfcn,x0,x,ydata,[],[],opts)
I get the error "not enough input arguments" in my objfcn, and it still outputs the initial guesses
Any help with why this isnt working or if im doing something really wrong is greatly appreciated! I am a novice Matlab user.
Thank you!! Hello,
I’ve been following the following link — https://www.mathworks.com/help/optim/ug/fit-model-to-complex-data.html#
to try and extract the real constants (N_s,Tau_s, and c) from the Drude-Smith derivation for complex conductivity. This involves fitting both the real and imaginary components (which may be the problem in itself, since the example fits regular data with complex noise?)
I’ve attempted both lsqnonlin and lsqcurve fit methods.
file =[‘DSfit_Sitest.xls’]; %%file attached
input = xlsread(file);
x = input(:,1); %%%% xdata, freqency, omega, real numbers from (0.2-1.4 THz)
R = input(:,2); %%%% Real component (blue in plot)
I = input(:,3);%%%% Imaginary component (orange in plot)
ydata = complex(R,I); %%%% complex conductivity, sigma_s
q = 1.602E-19; %% charge
m = 0.98; %% effective electron mass
mi = 1/0.98; %% inverse electron mass used to make typing the equation simpler
objfcn = @(C)(((C(1)*(q^2)*mi*C(2))./(1-1i.*x.*C(2))).*(1+(C(3)./(1-1i.*x.*C(2))))) – ydata;
opts = optimoptions(@lsqnonlin,’Display’,’off’);
x0=[1e17, 100, -0.1]; %% initial guesses, I expect these to be reasonable values
LB = [1e15, 1, -1]; %%Typical carrier concentrations (cm-3), Tau_s (C(2)) units in picoseconds, -1<c<0
UB = [1e21, 1000, 0];
[const,~,residual,exitflag,output] = lsqnonlin(objfcn,x0,[],[],opts); %% does not run with LB and UB, so i leave blank.
This method outputs the initial guesses, and when I use the initial guesses to plot the outputs I get my data graph flipped, meaning my function just equals zero.
Using lsqcurvefit
objfcn = @(C,x)(((C(1)*(q^2).*mi.*C(2))./(1-1i.*x.*C(2))).*(1+(C(3)./(1-1i.*x.*C(2)))));
opts = optimoptions(@lsqcurvefit,opts);
x0=[1e17, 100, -0.1];
LB = [1e15, 1, -1];
UB = [1e21, 1e3, 0];
[constan,resnorm] = lsqcurvefit(objfcn,x0,x,ydata,[],[],opts)
I get the error "not enough input arguments" in my objfcn, and it still outputs the initial guesses
Any help with why this isnt working or if im doing something really wrong is greatly appreciated! I am a novice Matlab user.
Thank you!! complex curve fitting, curvefitting, lsqcurvefit, lsqnonlin, complex data, drude-smith MATLAB Answers — New Questions