Category: Matlab
Category Archives: Matlab
How to uncheck all other checkboxes when one is selected in App Designer Table
I have a UITable in App Desinger. The first column is logical and therefore displays editable checkboxes. My objective is to have all other checkboxes cleared (unchecked) after I select a single check box. My current section of code is the following:
% Callbacks that handle component events
methods (Access = private)
% Cell edit callback: UITable
function UITableCellEdit(app, event)
% If the edited column is the checkbox column
if event.Indices(2) == 1
% Uncheck other checkboxes in the column after selection
if event.NewData
app.UITable.Data(:, 1) = {false};
end
app.UITable.Data{event.Indices(1), 1} = event.NewData; % Check the clicked checkbox
end
end
end
However, when I run the app I can still have multiple checkboxes selected at a time. This is not my intended effect. Again, I only want one checkbox to be able to be selected at a time; when one is selected all others should be cleared.I have a UITable in App Desinger. The first column is logical and therefore displays editable checkboxes. My objective is to have all other checkboxes cleared (unchecked) after I select a single check box. My current section of code is the following:
% Callbacks that handle component events
methods (Access = private)
% Cell edit callback: UITable
function UITableCellEdit(app, event)
% If the edited column is the checkbox column
if event.Indices(2) == 1
% Uncheck other checkboxes in the column after selection
if event.NewData
app.UITable.Data(:, 1) = {false};
end
app.UITable.Data{event.Indices(1), 1} = event.NewData; % Check the clicked checkbox
end
end
end
However, when I run the app I can still have multiple checkboxes selected at a time. This is not my intended effect. Again, I only want one checkbox to be able to be selected at a time; when one is selected all others should be cleared. I have a UITable in App Desinger. The first column is logical and therefore displays editable checkboxes. My objective is to have all other checkboxes cleared (unchecked) after I select a single check box. My current section of code is the following:
% Callbacks that handle component events
methods (Access = private)
% Cell edit callback: UITable
function UITableCellEdit(app, event)
% If the edited column is the checkbox column
if event.Indices(2) == 1
% Uncheck other checkboxes in the column after selection
if event.NewData
app.UITable.Data(:, 1) = {false};
end
app.UITable.Data{event.Indices(1), 1} = event.NewData; % Check the clicked checkbox
end
end
end
However, when I run the app I can still have multiple checkboxes selected at a time. This is not my intended effect. Again, I only want one checkbox to be able to be selected at a time; when one is selected all others should be cleared. checkbox, uitable MATLAB Answers — New Questions
dir results are not fitting the wildcard
Dear all,
thanks in advance for reading this question which seems kind of dumb to me but i need a solution for this issue. a workaround would be easy but not nice.
i use the dir command with a wildcard to find files in a folder but the returned file names do not fit the wildcard:
dir(‘O:FIP2015WW007IGB1M2014_12_23_10_36*RGB*.cr2’)
2014_12_23_FWW0070150.CR2 2014_12_23_FWW0070156.CR2
2014_12_23_FWW0070151.CR2 2014_12_23_FWW0070157.CR2
2014_12_23_FWW0070152.CR2 2014_12_23_FWW0070158.CR2
2014_12_23_FWW0070153.CR2 2014_12_23_FWW0070159.CR2
2014_12_23_FWW0070154.CR2
2014_12_23_FWW0070155.CR2
I use matlab 2022b and would be happy for a fix.
many thanksDear all,
thanks in advance for reading this question which seems kind of dumb to me but i need a solution for this issue. a workaround would be easy but not nice.
i use the dir command with a wildcard to find files in a folder but the returned file names do not fit the wildcard:
dir(‘O:FIP2015WW007IGB1M2014_12_23_10_36*RGB*.cr2’)
2014_12_23_FWW0070150.CR2 2014_12_23_FWW0070156.CR2
2014_12_23_FWW0070151.CR2 2014_12_23_FWW0070157.CR2
2014_12_23_FWW0070152.CR2 2014_12_23_FWW0070158.CR2
2014_12_23_FWW0070153.CR2 2014_12_23_FWW0070159.CR2
2014_12_23_FWW0070154.CR2
2014_12_23_FWW0070155.CR2
I use matlab 2022b and would be happy for a fix.
many thanks Dear all,
thanks in advance for reading this question which seems kind of dumb to me but i need a solution for this issue. a workaround would be easy but not nice.
i use the dir command with a wildcard to find files in a folder but the returned file names do not fit the wildcard:
dir(‘O:FIP2015WW007IGB1M2014_12_23_10_36*RGB*.cr2’)
2014_12_23_FWW0070150.CR2 2014_12_23_FWW0070156.CR2
2014_12_23_FWW0070151.CR2 2014_12_23_FWW0070157.CR2
2014_12_23_FWW0070152.CR2 2014_12_23_FWW0070158.CR2
2014_12_23_FWW0070153.CR2 2014_12_23_FWW0070159.CR2
2014_12_23_FWW0070154.CR2
2014_12_23_FWW0070155.CR2
I use matlab 2022b and would be happy for a fix.
many thanks dir wildcard MATLAB Answers — New Questions
How can I avoid extra white lines when exporting a figure to a vector graphic?
I have a Matlab figure that looks great as a figure, but when I try to export it to a vector-based format (.eps or .pdf) white swirly lines appear as can be seen in the linked PDF. Some of the black dots also get partially covered, despite being much higher in the 3D graph than everything else, but that can be easily fixed in Inkscape.
I have also attempted to generate a .pdf or .eps using my preferred method, through "export_fig," but have ended up with the same results. Any tips would be much appreciated! The .fig file has also been attached.I have a Matlab figure that looks great as a figure, but when I try to export it to a vector-based format (.eps or .pdf) white swirly lines appear as can be seen in the linked PDF. Some of the black dots also get partially covered, despite being much higher in the 3D graph than everything else, but that can be easily fixed in Inkscape.
I have also attempted to generate a .pdf or .eps using my preferred method, through "export_fig," but have ended up with the same results. Any tips would be much appreciated! The .fig file has also been attached. I have a Matlab figure that looks great as a figure, but when I try to export it to a vector-based format (.eps or .pdf) white swirly lines appear as can be seen in the linked PDF. Some of the black dots also get partially covered, despite being much higher in the 3D graph than everything else, but that can be easily fixed in Inkscape.
I have also attempted to generate a .pdf or .eps using my preferred method, through "export_fig," but have ended up with the same results. Any tips would be much appreciated! The .fig file has also been attached. figure, export, pdf, eps MATLAB Answers — New Questions
how can i blur the background?
Hello, I want to blur the background not the man. please help as soon as possible.Hello, I want to blur the background not the man. please help as soon as possible. Hello, I want to blur the background not the man. please help as soon as possible. image analysis MATLAB Answers — New Questions
Resonant frequency of LLC resonant converter from a quality factor curve
Hii, Can anyone help me to understand how to determine resonant frequnecy from a quality factor curve for my further calculation ?
i have attached an image of the quality curve that I’ve obtained in matlab.Hii, Can anyone help me to understand how to determine resonant frequnecy from a quality factor curve for my further calculation ?
i have attached an image of the quality curve that I’ve obtained in matlab. Hii, Can anyone help me to understand how to determine resonant frequnecy from a quality factor curve for my further calculation ?
i have attached an image of the quality curve that I’ve obtained in matlab. resonance frequnecy, llc resonant converter, simulink, q factor curve MATLAB Answers — New Questions
How to identify data set characteristics which influence the success of a model using those data sets as input.
I am studying the effect of hurricanes on coral reefs and have developed a damage prediction model which uses as inputs the fragility and distribution of different coral species at 150 post-storm survey sites. I can also create multiple simulated reefs by randomly assigning species, colonies and damage from the measured probability distribution functions of those parqameters for each species. When I make 1000 simulated reef experiments the results of my damage prediction are widly distributed from terrible to great. I need to mine the 1000 simultaed reefs to identify patterns which are influencing the success of the model. I expect this is a common scenario and would apprecieate any guidance on which tools to use and how to proceed. I have the statistics and machine learning toolbox.I am studying the effect of hurricanes on coral reefs and have developed a damage prediction model which uses as inputs the fragility and distribution of different coral species at 150 post-storm survey sites. I can also create multiple simulated reefs by randomly assigning species, colonies and damage from the measured probability distribution functions of those parqameters for each species. When I make 1000 simulated reef experiments the results of my damage prediction are widly distributed from terrible to great. I need to mine the 1000 simultaed reefs to identify patterns which are influencing the success of the model. I expect this is a common scenario and would apprecieate any guidance on which tools to use and how to proceed. I have the statistics and machine learning toolbox. I am studying the effect of hurricanes on coral reefs and have developed a damage prediction model which uses as inputs the fragility and distribution of different coral species at 150 post-storm survey sites. I can also create multiple simulated reefs by randomly assigning species, colonies and damage from the measured probability distribution functions of those parqameters for each species. When I make 1000 simulated reef experiments the results of my damage prediction are widly distributed from terrible to great. I need to mine the 1000 simultaed reefs to identify patterns which are influencing the success of the model. I expect this is a common scenario and would apprecieate any guidance on which tools to use and how to proceed. I have the statistics and machine learning toolbox. data mining, clustering, datasets MATLAB Answers — New Questions
4.2 Whiteboard Coordinate System Error for Function
I am currently going through the Arudino Matlab Engeering Kit, starting with the drawing Robot, and ran into a coding error message that I can not figure out. My code:
function xy = countsToXY(counts,Z_i,Base) % Define constants
countsPerRadian = countsPerRevolution/(2*pi);
r_spool = 0.0045; % Convert counts to angle
phi = counts/countsPerRadian; % Convert angle to change in string length
dStringLength = r_spool*phi; % Convert change in string length to change in Z
dZ = dStringLength/2; %Add change in Z to initial Z to get current Z
z = Z_i + dz; % Compute x and y from Z1 and Z2
x = (Base^2 + z(1)^2 – z(2)^2)/(2*Base);
y = sqrt(z(1)^2-x^2); xy = [x y];
end
But the error that I keep getting is:
Error: File: countsToXY.m Line: 2 Column: 46
Invalid use of operator.
Is there something that I’m missing or was not explained within the lesson that I need to run this code?I am currently going through the Arudino Matlab Engeering Kit, starting with the drawing Robot, and ran into a coding error message that I can not figure out. My code:
function xy = countsToXY(counts,Z_i,Base) % Define constants
countsPerRadian = countsPerRevolution/(2*pi);
r_spool = 0.0045; % Convert counts to angle
phi = counts/countsPerRadian; % Convert angle to change in string length
dStringLength = r_spool*phi; % Convert change in string length to change in Z
dZ = dStringLength/2; %Add change in Z to initial Z to get current Z
z = Z_i + dz; % Compute x and y from Z1 and Z2
x = (Base^2 + z(1)^2 – z(2)^2)/(2*Base);
y = sqrt(z(1)^2-x^2); xy = [x y];
end
But the error that I keep getting is:
Error: File: countsToXY.m Line: 2 Column: 46
Invalid use of operator.
Is there something that I’m missing or was not explained within the lesson that I need to run this code? I am currently going through the Arudino Matlab Engeering Kit, starting with the drawing Robot, and ran into a coding error message that I can not figure out. My code:
function xy = countsToXY(counts,Z_i,Base) % Define constants
countsPerRadian = countsPerRevolution/(2*pi);
r_spool = 0.0045; % Convert counts to angle
phi = counts/countsPerRadian; % Convert angle to change in string length
dStringLength = r_spool*phi; % Convert change in string length to change in Z
dZ = dStringLength/2; %Add change in Z to initial Z to get current Z
z = Z_i + dz; % Compute x and y from Z1 and Z2
x = (Base^2 + z(1)^2 – z(2)^2)/(2*Base);
y = sqrt(z(1)^2-x^2); xy = [x y];
end
But the error that I keep getting is:
Error: File: countsToXY.m Line: 2 Column: 46
Invalid use of operator.
Is there something that I’m missing or was not explained within the lesson that I need to run this code? arduino, code, matlab, drawing robot MATLAB Answers — New Questions
Compare two files and remove any lines in the second file when they match values found in the first file
Dear all,
I was wondering if there is a way in matlab to compare to files and remove the lines in file2 that match values in file1.
I used in the past visdiff to compare files, but I would like to understand if, using the same function, I can remove the lines that matches between the two files.
Some of you has some ideas to suggest?
Thanks to whoever help me.
ChiaraDear all,
I was wondering if there is a way in matlab to compare to files and remove the lines in file2 that match values in file1.
I used in the past visdiff to compare files, but I would like to understand if, using the same function, I can remove the lines that matches between the two files.
Some of you has some ideas to suggest?
Thanks to whoever help me.
Chiara Dear all,
I was wondering if there is a way in matlab to compare to files and remove the lines in file2 that match values in file1.
I used in the past visdiff to compare files, but I would like to understand if, using the same function, I can remove the lines that matches between the two files.
Some of you has some ideas to suggest?
Thanks to whoever help me.
Chiara two-file comparison, remove lines that matches MATLAB Answers — New Questions
GIBBS SAMPLING FOR N DISCRETE VARIABLES IN A N-SPACE
Dear all,
I would like to ask how can be perfomed a Gibbs sampling for a space constituted by n discrete distributions. As an example, I provide 5 distributions with different data, different size, and different p(data), which represent the posterior probability:
– data1 = [50 70 100 130 170 230 300 400]; p(data1) = [0.20 0.05 0.05 0.10 0.09 0.01 0.28 0.22];
– data2 = [1 2 3 4 5 6 7 8]; p(data2) = [0.05 0.1 0.25 0.1 0.05 0.05 0.2 0.2];
– data3 = [1 2 3 4]; p(data3) = [0.3 0.5 0.1 0.1];
– data4 = [1 2]; p(data4) = [0.85 0.15];
– data5 = [1 2]; p(data5) = [0.9 0.1];Dear all,
I would like to ask how can be perfomed a Gibbs sampling for a space constituted by n discrete distributions. As an example, I provide 5 distributions with different data, different size, and different p(data), which represent the posterior probability:
– data1 = [50 70 100 130 170 230 300 400]; p(data1) = [0.20 0.05 0.05 0.10 0.09 0.01 0.28 0.22];
– data2 = [1 2 3 4 5 6 7 8]; p(data2) = [0.05 0.1 0.25 0.1 0.05 0.05 0.2 0.2];
– data3 = [1 2 3 4]; p(data3) = [0.3 0.5 0.1 0.1];
– data4 = [1 2]; p(data4) = [0.85 0.15];
– data5 = [1 2]; p(data5) = [0.9 0.1]; Dear all,
I would like to ask how can be perfomed a Gibbs sampling for a space constituted by n discrete distributions. As an example, I provide 5 distributions with different data, different size, and different p(data), which represent the posterior probability:
– data1 = [50 70 100 130 170 230 300 400]; p(data1) = [0.20 0.05 0.05 0.10 0.09 0.01 0.28 0.22];
– data2 = [1 2 3 4 5 6 7 8]; p(data2) = [0.05 0.1 0.25 0.1 0.05 0.05 0.2 0.2];
– data3 = [1 2 3 4]; p(data3) = [0.3 0.5 0.1 0.1];
– data4 = [1 2]; p(data4) = [0.85 0.15];
– data5 = [1 2]; p(data5) = [0.9 0.1]; sampling, statistics, gibbs, discrete variables MATLAB Answers — New Questions
what is my activation key?
i want to get my activation key .i want to get my activation key . i want to get my activation key . upgrading, activation key, installation MATLAB Answers — New Questions
Issue with image background substraction
Hi,
I am trying to perform background substraction. Here I have both the main and background images. I tried imsubstract unfortunately that doesn’t performing well.Hi,
I am trying to perform background substraction. Here I have both the main and background images. I tried imsubstract unfortunately that doesn’t performing well. Hi,
I am trying to perform background substraction. Here I have both the main and background images. I tried imsubstract unfortunately that doesn’t performing well. image processing, image background substraction, imsubstract, binary image MATLAB Answers — New Questions
Connect Matlab to PureData?
Hello,
I have a heavy code that runs in Matlab which gives me eventually lots of acoustic information as an output for some input parameters.
PureData (https://puredata.info/) is another programming language that I require to do some audio/acoustic post-processing. This can only be done in PureData. For this i need the code in PureData and Matlab to communicate in real time.
I plan to make a PureData code with the core of it being a Matlab code so that the PureData code can post-process it without delay.
Until now i was running the Matlab code and saving each data point on the locally and the running the PureData code after that.
Is there anyway to connect both of them locally so that both codes runs as one (Matlab nested in PureData)?
Any help is appreciated.
Thank you!!
David.Hello,
I have a heavy code that runs in Matlab which gives me eventually lots of acoustic information as an output for some input parameters.
PureData (https://puredata.info/) is another programming language that I require to do some audio/acoustic post-processing. This can only be done in PureData. For this i need the code in PureData and Matlab to communicate in real time.
I plan to make a PureData code with the core of it being a Matlab code so that the PureData code can post-process it without delay.
Until now i was running the Matlab code and saving each data point on the locally and the running the PureData code after that.
Is there anyway to connect both of them locally so that both codes runs as one (Matlab nested in PureData)?
Any help is appreciated.
Thank you!!
David. Hello,
I have a heavy code that runs in Matlab which gives me eventually lots of acoustic information as an output for some input parameters.
PureData (https://puredata.info/) is another programming language that I require to do some audio/acoustic post-processing. This can only be done in PureData. For this i need the code in PureData and Matlab to communicate in real time.
I plan to make a PureData code with the core of it being a Matlab code so that the PureData code can post-process it without delay.
Until now i was running the Matlab code and saving each data point on the locally and the running the PureData code after that.
Is there anyway to connect both of them locally so that both codes runs as one (Matlab nested in PureData)?
Any help is appreciated.
Thank you!!
David. matlab, puredata, communication, real time, optimization, tcp MATLAB Answers — New Questions
Incorrect number or types of inputs or outputs for function perturb.
n = 100;
A = rand(n);
AInv = inv(A);
x = ones(n, 1);
b = A * x;
bTilde = perturb(b, 1e-10);
xApp = Ab;
xTildeApp = AbTilde;
disp(‘x minus xTilde’)
xdiff = norm(xApp-xTildeApp)/norm(xApp);
disp(‘b minus bTilde’)
bDiff = norm(b-bTilde)/norm(b);
disp(‘estimate’)
normA = norm(A);
normAInv = norm(AInv);
estimate = normA*normAInv*bDiff
What’s wrong with perturb function input?n = 100;
A = rand(n);
AInv = inv(A);
x = ones(n, 1);
b = A * x;
bTilde = perturb(b, 1e-10);
xApp = Ab;
xTildeApp = AbTilde;
disp(‘x minus xTilde’)
xdiff = norm(xApp-xTildeApp)/norm(xApp);
disp(‘b minus bTilde’)
bDiff = norm(b-bTilde)/norm(b);
disp(‘estimate’)
normA = norm(A);
normAInv = norm(AInv);
estimate = normA*normAInv*bDiff
What’s wrong with perturb function input? n = 100;
A = rand(n);
AInv = inv(A);
x = ones(n, 1);
b = A * x;
bTilde = perturb(b, 1e-10);
xApp = Ab;
xTildeApp = AbTilde;
disp(‘x minus xTilde’)
xdiff = norm(xApp-xTildeApp)/norm(xApp);
disp(‘b minus bTilde’)
bDiff = norm(b-bTilde)/norm(b);
disp(‘estimate’)
normA = norm(A);
normAInv = norm(AInv);
estimate = normA*normAInv*bDiff
What’s wrong with perturb function input? perturb, function, linear algebra, matlab MATLAB Answers — New Questions
Download Matlab 2014 a
kindly i need the installation file of matlab2014akindly i need the installation file of matlab2014a kindly i need the installation file of matlab2014a matlab2014a MATLAB Answers — New Questions
How can I count the number of times a number appear in a vector?
How can I count the number of times a number appear in a vector?
A=[ 1 2 3 1 1 6 3 4 2 2 1 1 1 ]
1 appears 7 times
2 appears 3 times
3 appears 3 times
and on
…
Best RegardsHow can I count the number of times a number appear in a vector?
A=[ 1 2 3 1 1 6 3 4 2 2 1 1 1 ]
1 appears 7 times
2 appears 3 times
3 appears 3 times
and on
…
Best Regards How can I count the number of times a number appear in a vector?
A=[ 1 2 3 1 1 6 3 4 2 2 1 1 1 ]
1 appears 7 times
2 appears 3 times
3 appears 3 times
and on
…
Best Regards count, number of times, histogram MATLAB Answers — New Questions
Error: File: untitled5 Line: 19 Column: 1 Function definitions in a script must appear at the end of the file. Move all statements after the “f” function definition to before
% Define parameters
m = 1;
L = 16;
g = 9.81;
H = -22;
theta_0 = -deg2rad(170); % Convert initial angle to radians
theta_B = deg2rad(55);
a=0;
% Calculate initial angular velocity
omega_B = sqrt(g / L * (1 – cos(theta_B)));
% Define ODEs
function dy = f(t, y)
dy(1) = y(2);
dy(2) = -g;
end
% Initial conditions
[a, omega_B ] = y0;
% Solve ODEs
[t, y] = ode45(@f, [0, sqrt(2 * (H + L * (1 – cos(theta_B))) / g)], y0);
% Horizontal coordinate of landing point
X = y(end, 1);
% Round to nearest whole number
X = round(X);
% Display result
disp([‘Horizontal coordinate of landing point (X): ‘, num2str(X), ‘ meters’]);% Define parameters
m = 1;
L = 16;
g = 9.81;
H = -22;
theta_0 = -deg2rad(170); % Convert initial angle to radians
theta_B = deg2rad(55);
a=0;
% Calculate initial angular velocity
omega_B = sqrt(g / L * (1 – cos(theta_B)));
% Define ODEs
function dy = f(t, y)
dy(1) = y(2);
dy(2) = -g;
end
% Initial conditions
[a, omega_B ] = y0;
% Solve ODEs
[t, y] = ode45(@f, [0, sqrt(2 * (H + L * (1 – cos(theta_B))) / g)], y0);
% Horizontal coordinate of landing point
X = y(end, 1);
% Round to nearest whole number
X = round(X);
% Display result
disp([‘Horizontal coordinate of landing point (X): ‘, num2str(X), ‘ meters’]); % Define parameters
m = 1;
L = 16;
g = 9.81;
H = -22;
theta_0 = -deg2rad(170); % Convert initial angle to radians
theta_B = deg2rad(55);
a=0;
% Calculate initial angular velocity
omega_B = sqrt(g / L * (1 – cos(theta_B)));
% Define ODEs
function dy = f(t, y)
dy(1) = y(2);
dy(2) = -g;
end
% Initial conditions
[a, omega_B ] = y0;
% Solve ODEs
[t, y] = ode45(@f, [0, sqrt(2 * (H + L * (1 – cos(theta_B))) / g)], y0);
% Horizontal coordinate of landing point
X = y(end, 1);
% Round to nearest whole number
X = round(X);
% Display result
disp([‘Horizontal coordinate of landing point (X): ‘, num2str(X), ‘ meters’]); task-6 (projectile motion: linear versus non-linea MATLAB Answers — New Questions
when making custom PCB and pcb trace, what is the thickness of the trace?
I follow this tutorial for making PCB trace and simulating it under different frequencies.
What I fail to find in the documentation and tutorial, is what is the thickness of the trace/GND plane I am making? (In the default microstrip line).
It seems like I can only change the
d.Thickness
I tried to run
trace.Thickness
It gives me:
Unrecognized method, property, or field ‘Thickness’ for class ‘traceLine’.I follow this tutorial for making PCB trace and simulating it under different frequencies.
What I fail to find in the documentation and tutorial, is what is the thickness of the trace/GND plane I am making? (In the default microstrip line).
It seems like I can only change the
d.Thickness
I tried to run
trace.Thickness
It gives me:
Unrecognized method, property, or field ‘Thickness’ for class ‘traceLine’. I follow this tutorial for making PCB trace and simulating it under different frequencies.
What I fail to find in the documentation and tutorial, is what is the thickness of the trace/GND plane I am making? (In the default microstrip line).
It seems like I can only change the
d.Thickness
I tried to run
trace.Thickness
It gives me:
Unrecognized method, property, or field ‘Thickness’ for class ‘traceLine’. pcb, thickness, trace MATLAB Answers — New Questions
pv array mppt model doesn’t work as expected
this simulation is a pv array connected with a buck boost converter and a mppt algorithm, the problem is even though the pv plots are correct the voltage does’nt seem to be tkane into consideration when calculation the final output power, and the load power and pv array power should be the same but they’re not and idk why i checked pretty much everythingthis simulation is a pv array connected with a buck boost converter and a mppt algorithm, the problem is even though the pv plots are correct the voltage does’nt seem to be tkane into consideration when calculation the final output power, and the load power and pv array power should be the same but they’re not and idk why i checked pretty much everything this simulation is a pv array connected with a buck boost converter and a mppt algorithm, the problem is even though the pv plots are correct the voltage does’nt seem to be tkane into consideration when calculation the final output power, and the load power and pv array power should be the same but they’re not and idk why i checked pretty much everything simulink, optimization, array, matlab function MATLAB Answers — New Questions
fminsearch doesn’t converge to the right value
Hi all,
I am trying to solve and minimize the following exponential fit, trying to retrieve the exponential term.
I am using fminsearch to minimize the "sum-squared-error cost function" but somehow it is not really working. I am sure I am making some stupid mistake but I can’t figure it out … It should give me back the 0.1 value but never really get it (even if noise is 0).
Here the code:
x=0:100;
y=exp(-0.1*x)’+0.1*rand(101,1);
plot(x,y)
hold on
%%
[h, ff, s] = sc(0.5, x, y)
plot(x, y)
plot(x,h,x,y,x,ff)
% hold on
% s
function [h ff s]=sc(k, x, y)
co=[exp(-k*x)’ ones(size(y))]y;
%
% ff=co(1)*exp(-k*x)’+co(2)*ones(size(y));
% h=y-ff;
% s=sum(h.^2);
%
ff = @(k,x) co(1).*exp(-k.*x)’+co(2).*ones(size(y));
h = @(k) sum((y-ff(k,x)).^2);
options = optimset(‘PlotFcns’,@optimplotfval,’Display’,’iter’);
s = fminsearch(h,k,options);
ff=exp(-s*x)’+co(2)*ones(size(y));
h=y-ff;
end
Thanks for help,
EHi all,
I am trying to solve and minimize the following exponential fit, trying to retrieve the exponential term.
I am using fminsearch to minimize the "sum-squared-error cost function" but somehow it is not really working. I am sure I am making some stupid mistake but I can’t figure it out … It should give me back the 0.1 value but never really get it (even if noise is 0).
Here the code:
x=0:100;
y=exp(-0.1*x)’+0.1*rand(101,1);
plot(x,y)
hold on
%%
[h, ff, s] = sc(0.5, x, y)
plot(x, y)
plot(x,h,x,y,x,ff)
% hold on
% s
function [h ff s]=sc(k, x, y)
co=[exp(-k*x)’ ones(size(y))]y;
%
% ff=co(1)*exp(-k*x)’+co(2)*ones(size(y));
% h=y-ff;
% s=sum(h.^2);
%
ff = @(k,x) co(1).*exp(-k.*x)’+co(2).*ones(size(y));
h = @(k) sum((y-ff(k,x)).^2);
options = optimset(‘PlotFcns’,@optimplotfval,’Display’,’iter’);
s = fminsearch(h,k,options);
ff=exp(-s*x)’+co(2)*ones(size(y));
h=y-ff;
end
Thanks for help,
E Hi all,
I am trying to solve and minimize the following exponential fit, trying to retrieve the exponential term.
I am using fminsearch to minimize the "sum-squared-error cost function" but somehow it is not really working. I am sure I am making some stupid mistake but I can’t figure it out … It should give me back the 0.1 value but never really get it (even if noise is 0).
Here the code:
x=0:100;
y=exp(-0.1*x)’+0.1*rand(101,1);
plot(x,y)
hold on
%%
[h, ff, s] = sc(0.5, x, y)
plot(x, y)
plot(x,h,x,y,x,ff)
% hold on
% s
function [h ff s]=sc(k, x, y)
co=[exp(-k*x)’ ones(size(y))]y;
%
% ff=co(1)*exp(-k*x)’+co(2)*ones(size(y));
% h=y-ff;
% s=sum(h.^2);
%
ff = @(k,x) co(1).*exp(-k.*x)’+co(2).*ones(size(y));
h = @(k) sum((y-ff(k,x)).^2);
options = optimset(‘PlotFcns’,@optimplotfval,’Display’,’iter’);
s = fminsearch(h,k,options);
ff=exp(-s*x)’+co(2)*ones(size(y));
h=y-ff;
end
Thanks for help,
E fminsearch, curve fitting MATLAB Answers — New Questions
The steady-state density matrix ρ by solving the master equation.
I need help in writting code for numerical solution of master equation for given Hamiltonian.I need help in writting code for numerical solution of master equation for given Hamiltonian. I need help in writting code for numerical solution of master equation for given Hamiltonian. master equation MATLAB Answers — New Questions