Category: Matlab
Category Archives: Matlab
how do I implement a real time FFT in simulink?
I need to implement a real time FFT of the signal in the attached simulink model in order to detect the frequency and phase of the highest peak (it’s a single sinusoid, so it shouldn’t be an issue). As you can see, I’ve set the simulation step to 1/48000. I would like the detection update rate to be 40Hz, so the FFT is run 40 times a second. I’d like the FFT to be run on the newest samples (i.e. 48000/40) plus an overlap of 50% of the previous set (48000/80), so in other words, the latest 1800 samples. I’d like to zero pad this up to the next power of 2.
I was trying to figure out how to do a FIFO buffer that saves the last 1800 samples, but I couldn’t figure that out, and I couldn’t advance past that stage.
In case it helps, here’s what I have:
Simulink Version 24.2 (R2024b)
Control System Toolbox Version 24.2 (R2024b)
DSP System Toolbox Version 24.2 (R2024b)
Optimization Toolbox Version 24.2 (R2024b)
Signal Processing Toolbox Version 24.2 (R2024b)
Stateflow Version 24.2 (R2024b)
Statistics and Machine Learning Toolbox Version 24.2 (R2024b)
Thanks in advance
-BastianI need to implement a real time FFT of the signal in the attached simulink model in order to detect the frequency and phase of the highest peak (it’s a single sinusoid, so it shouldn’t be an issue). As you can see, I’ve set the simulation step to 1/48000. I would like the detection update rate to be 40Hz, so the FFT is run 40 times a second. I’d like the FFT to be run on the newest samples (i.e. 48000/40) plus an overlap of 50% of the previous set (48000/80), so in other words, the latest 1800 samples. I’d like to zero pad this up to the next power of 2.
I was trying to figure out how to do a FIFO buffer that saves the last 1800 samples, but I couldn’t figure that out, and I couldn’t advance past that stage.
In case it helps, here’s what I have:
Simulink Version 24.2 (R2024b)
Control System Toolbox Version 24.2 (R2024b)
DSP System Toolbox Version 24.2 (R2024b)
Optimization Toolbox Version 24.2 (R2024b)
Signal Processing Toolbox Version 24.2 (R2024b)
Stateflow Version 24.2 (R2024b)
Statistics and Machine Learning Toolbox Version 24.2 (R2024b)
Thanks in advance
-Bastian I need to implement a real time FFT of the signal in the attached simulink model in order to detect the frequency and phase of the highest peak (it’s a single sinusoid, so it shouldn’t be an issue). As you can see, I’ve set the simulation step to 1/48000. I would like the detection update rate to be 40Hz, so the FFT is run 40 times a second. I’d like the FFT to be run on the newest samples (i.e. 48000/40) plus an overlap of 50% of the previous set (48000/80), so in other words, the latest 1800 samples. I’d like to zero pad this up to the next power of 2.
I was trying to figure out how to do a FIFO buffer that saves the last 1800 samples, but I couldn’t figure that out, and I couldn’t advance past that stage.
In case it helps, here’s what I have:
Simulink Version 24.2 (R2024b)
Control System Toolbox Version 24.2 (R2024b)
DSP System Toolbox Version 24.2 (R2024b)
Optimization Toolbox Version 24.2 (R2024b)
Signal Processing Toolbox Version 24.2 (R2024b)
Stateflow Version 24.2 (R2024b)
Statistics and Machine Learning Toolbox Version 24.2 (R2024b)
Thanks in advance
-Bastian fft MATLAB Answers — New Questions
How to calculate only several frequency with FFT ?
Almost all cases, 1st, use FFT2 transfer to frequency field all , then to analysis like filter.
If I know only some frequecy are need,
Is it possible to calculate only several frequency not all frequencies with FFT ?
If OK, How to do?
for example, if ther are 512 data points, then will get 512 data points at frequency field, but I only need 0~50Hz,
How to tall FFT no need to calculated those dat more than 50Hz ?
Like sparse , but not source dat sparse, is the transfer tanget is sparse .Almost all cases, 1st, use FFT2 transfer to frequency field all , then to analysis like filter.
If I know only some frequecy are need,
Is it possible to calculate only several frequency not all frequencies with FFT ?
If OK, How to do?
for example, if ther are 512 data points, then will get 512 data points at frequency field, but I only need 0~50Hz,
How to tall FFT no need to calculated those dat more than 50Hz ?
Like sparse , but not source dat sparse, is the transfer tanget is sparse . Almost all cases, 1st, use FFT2 transfer to frequency field all , then to analysis like filter.
If I know only some frequecy are need,
Is it possible to calculate only several frequency not all frequencies with FFT ?
If OK, How to do?
for example, if ther are 512 data points, then will get 512 data points at frequency field, but I only need 0~50Hz,
How to tall FFT no need to calculated those dat more than 50Hz ?
Like sparse , but not source dat sparse, is the transfer tanget is sparse . fft, sparse MATLAB Answers — New Questions
Effect of prediction horizon on objective cost in “Landing Rocket With MPC Example”
The Matlab example "Landing a Vehicle Using Multistage Nonlinear MPC" (which can be found here), uses a multistage nonlinear MPC to perform the trajectory optimization and another multistage nonlinear MPC to do the motion control. In the script, the former is called the "planner" and the latter is called the "lander". My question is purely regarding the planner:
Why does the objective cost increase when the prediction horizon (p) increases?
Given the sample time Ts and prediction horizon p, the prediction time becomes Ts*p. Here are three configurations with their output from the fmincon() function that resides in the nlmpcmove() function. Except the values for Ts and p, all code is similar to the Matlab example given here.
Ts = 0.2; pPlanner = 45; leads to Objective cost = 445.5349
Ts = 0.2; pPlanner = 50; leads to Objective cost = 492.9689
Ts = 0.2; pPlanner = 55; leads to Objective cost = 541.1668
To my understanding, a larger prediction horizon should give room to a more optimized result. Suppose the ideal trajectory takes Ts*p = 0.2*45 = 9 seconds. Why would the configuration with 50 seconds not lead to the exact same results?
The answers is probably related to how the nlmpcmove() function uses the user provided cost function and terminal state to converge to a solution. What is the math behind this convergence?
I’m using Matlab R2021b. Related Toolboxes are: Model Predictive Control Toolbox and Optimization Toolbox.The Matlab example "Landing a Vehicle Using Multistage Nonlinear MPC" (which can be found here), uses a multistage nonlinear MPC to perform the trajectory optimization and another multistage nonlinear MPC to do the motion control. In the script, the former is called the "planner" and the latter is called the "lander". My question is purely regarding the planner:
Why does the objective cost increase when the prediction horizon (p) increases?
Given the sample time Ts and prediction horizon p, the prediction time becomes Ts*p. Here are three configurations with their output from the fmincon() function that resides in the nlmpcmove() function. Except the values for Ts and p, all code is similar to the Matlab example given here.
Ts = 0.2; pPlanner = 45; leads to Objective cost = 445.5349
Ts = 0.2; pPlanner = 50; leads to Objective cost = 492.9689
Ts = 0.2; pPlanner = 55; leads to Objective cost = 541.1668
To my understanding, a larger prediction horizon should give room to a more optimized result. Suppose the ideal trajectory takes Ts*p = 0.2*45 = 9 seconds. Why would the configuration with 50 seconds not lead to the exact same results?
The answers is probably related to how the nlmpcmove() function uses the user provided cost function and terminal state to converge to a solution. What is the math behind this convergence?
I’m using Matlab R2021b. Related Toolboxes are: Model Predictive Control Toolbox and Optimization Toolbox. The Matlab example "Landing a Vehicle Using Multistage Nonlinear MPC" (which can be found here), uses a multistage nonlinear MPC to perform the trajectory optimization and another multistage nonlinear MPC to do the motion control. In the script, the former is called the "planner" and the latter is called the "lander". My question is purely regarding the planner:
Why does the objective cost increase when the prediction horizon (p) increases?
Given the sample time Ts and prediction horizon p, the prediction time becomes Ts*p. Here are three configurations with their output from the fmincon() function that resides in the nlmpcmove() function. Except the values for Ts and p, all code is similar to the Matlab example given here.
Ts = 0.2; pPlanner = 45; leads to Objective cost = 445.5349
Ts = 0.2; pPlanner = 50; leads to Objective cost = 492.9689
Ts = 0.2; pPlanner = 55; leads to Objective cost = 541.1668
To my understanding, a larger prediction horizon should give room to a more optimized result. Suppose the ideal trajectory takes Ts*p = 0.2*45 = 9 seconds. Why would the configuration with 50 seconds not lead to the exact same results?
The answers is probably related to how the nlmpcmove() function uses the user provided cost function and terminal state to converge to a solution. What is the math behind this convergence?
I’m using Matlab R2021b. Related Toolboxes are: Model Predictive Control Toolbox and Optimization Toolbox. multistage nonlinear model predictive controller, landing rocket with mpc example MATLAB Answers — New Questions
Issue with Adaptive MPC in Simulink Using Online Pure Pursuit for Reference Path Generation
Hi there 🙂
I am facing an issue with my Simulink model, where an adaptive MPC controls the longitudinal and lateral dynamics of a vehicle with all-wheel steering and all-wheel drive. The MPC uses future reference values over the next 10 simulation steps within its prediction horizon. These reference paths are structured as [10×3] matrices, consisting of X, Y positions and orientation (Psi) in a 2D coordinate system.
Here’s my workflow:
I use a hybrid A* algorithm to generate a global path.
I use Pure Pursuit (PP) to create a local path from the current position to the LookAhead Point. PP runs in a loop 10 times to generate the structure of 10 future points for the MPC at each time step.
When using PP with an initial position that deviates from the global path, it successfully generates a meaningful local path leading to the global path and follows it accurately. If I pass this path offline to the MPC, the controller performs as expected, closely following the path.
Problem:
When I run the PP online in parallel with the MPC, feeding it the current positions from the plant system, I observe a discrepancy:
The PP outputs appear correct and provide reasonable reference suggestions.
However, the MPC seems not to implement these references properly.
Interestingly, the MPC produces different control signals when the reference path is generated online versus offline, even though the data and its structure ([10×3]) are identical in both cases.
Key Observations:
Offline paths work perfectly with the MPC.
Online paths generated by PP lead to unexpected MPC behavior, even though the output of PP looks correct.
Questions:
What could cause the adaptive MPC to behave differently when using online reference paths, despite their structure and data being identical to offline paths?
Are there specific considerations for feeding dynamically generated paths into an adaptive MPC during runtime?
Could this issue be related to timing, delays, or synchronization between the PP and MPC blocks in Simulink?
Any insights, suggestions, or debugging tips would be greatly appreciated!
Many thanks in advance and kind regards,
DanusHi there 🙂
I am facing an issue with my Simulink model, where an adaptive MPC controls the longitudinal and lateral dynamics of a vehicle with all-wheel steering and all-wheel drive. The MPC uses future reference values over the next 10 simulation steps within its prediction horizon. These reference paths are structured as [10×3] matrices, consisting of X, Y positions and orientation (Psi) in a 2D coordinate system.
Here’s my workflow:
I use a hybrid A* algorithm to generate a global path.
I use Pure Pursuit (PP) to create a local path from the current position to the LookAhead Point. PP runs in a loop 10 times to generate the structure of 10 future points for the MPC at each time step.
When using PP with an initial position that deviates from the global path, it successfully generates a meaningful local path leading to the global path and follows it accurately. If I pass this path offline to the MPC, the controller performs as expected, closely following the path.
Problem:
When I run the PP online in parallel with the MPC, feeding it the current positions from the plant system, I observe a discrepancy:
The PP outputs appear correct and provide reasonable reference suggestions.
However, the MPC seems not to implement these references properly.
Interestingly, the MPC produces different control signals when the reference path is generated online versus offline, even though the data and its structure ([10×3]) are identical in both cases.
Key Observations:
Offline paths work perfectly with the MPC.
Online paths generated by PP lead to unexpected MPC behavior, even though the output of PP looks correct.
Questions:
What could cause the adaptive MPC to behave differently when using online reference paths, despite their structure and data being identical to offline paths?
Are there specific considerations for feeding dynamically generated paths into an adaptive MPC during runtime?
Could this issue be related to timing, delays, or synchronization between the PP and MPC blocks in Simulink?
Any insights, suggestions, or debugging tips would be greatly appreciated!
Many thanks in advance and kind regards,
Danus Hi there 🙂
I am facing an issue with my Simulink model, where an adaptive MPC controls the longitudinal and lateral dynamics of a vehicle with all-wheel steering and all-wheel drive. The MPC uses future reference values over the next 10 simulation steps within its prediction horizon. These reference paths are structured as [10×3] matrices, consisting of X, Y positions and orientation (Psi) in a 2D coordinate system.
Here’s my workflow:
I use a hybrid A* algorithm to generate a global path.
I use Pure Pursuit (PP) to create a local path from the current position to the LookAhead Point. PP runs in a loop 10 times to generate the structure of 10 future points for the MPC at each time step.
When using PP with an initial position that deviates from the global path, it successfully generates a meaningful local path leading to the global path and follows it accurately. If I pass this path offline to the MPC, the controller performs as expected, closely following the path.
Problem:
When I run the PP online in parallel with the MPC, feeding it the current positions from the plant system, I observe a discrepancy:
The PP outputs appear correct and provide reasonable reference suggestions.
However, the MPC seems not to implement these references properly.
Interestingly, the MPC produces different control signals when the reference path is generated online versus offline, even though the data and its structure ([10×3]) are identical in both cases.
Key Observations:
Offline paths work perfectly with the MPC.
Online paths generated by PP lead to unexpected MPC behavior, even though the output of PP looks correct.
Questions:
What could cause the adaptive MPC to behave differently when using online reference paths, despite their structure and data being identical to offline paths?
Are there specific considerations for feeding dynamically generated paths into an adaptive MPC during runtime?
Could this issue be related to timing, delays, or synchronization between the PP and MPC blocks in Simulink?
Any insights, suggestions, or debugging tips would be greatly appreciated!
Many thanks in advance and kind regards,
Danus mpc MATLAB Answers — New Questions
Why my PMSM loses Torque suddenly after some time.
So, I have been modelling a EV model based of an article about the Bolt EV using simscape and I got a relatively ok model using the dc motor, but when trying to implement the PMSM I could not get good results from it, with weird torque and current responses. I do not have access to specifics parameters of the PMSM, what makes me suspect that it is the problem, but I am not sure how to estimate that with no access to the hardware to empiracally test it.So, I have been modelling a EV model based of an article about the Bolt EV using simscape and I got a relatively ok model using the dc motor, but when trying to implement the PMSM I could not get good results from it, with weird torque and current responses. I do not have access to specifics parameters of the PMSM, what makes me suspect that it is the problem, but I am not sure how to estimate that with no access to the hardware to empiracally test it. So, I have been modelling a EV model based of an article about the Bolt EV using simscape and I got a relatively ok model using the dc motor, but when trying to implement the PMSM I could not get good results from it, with weird torque and current responses. I do not have access to specifics parameters of the PMSM, what makes me suspect that it is the problem, but I am not sure how to estimate that with no access to the hardware to empiracally test it. simscape, simulink, electric_motor_control MATLAB Answers — New Questions
Generation of a unique library code declaration using Embedded coder
Hello team,
I have a library that is used inside multiple models. I am using Embedded coder to generate the code for these models.
Presently, the code generation for each of these models creates a separate instance of the library and its inside functions. However, to compile the complete software package, the library and its functions should have only one instance. We want only one definition/declaration for the library and its functions without using any additional prefix/suffix.
To avoid multiple function definition/declaration errors and achieve successful compilation, would you please provide a solution to generate a unique library code?Hello team,
I have a library that is used inside multiple models. I am using Embedded coder to generate the code for these models.
Presently, the code generation for each of these models creates a separate instance of the library and its inside functions. However, to compile the complete software package, the library and its functions should have only one instance. We want only one definition/declaration for the library and its functions without using any additional prefix/suffix.
To avoid multiple function definition/declaration errors and achieve successful compilation, would you please provide a solution to generate a unique library code? Hello team,
I have a library that is used inside multiple models. I am using Embedded coder to generate the code for these models.
Presently, the code generation for each of these models creates a separate instance of the library and its inside functions. However, to compile the complete software package, the library and its functions should have only one instance. We want only one definition/declaration for the library and its functions without using any additional prefix/suffix.
To avoid multiple function definition/declaration errors and achieve successful compilation, would you please provide a solution to generate a unique library code? embedded coder, simulink, masked library MATLAB Answers — New Questions
Why am I not getting proper gate signal and voltage
Hello Everyone,
I have been trying to follow the example model "PMSM Velocity Control" where my final objective is to replace the idela converter with parameterized discrete devices. For now, I am using ideal converter, with different reference speed (Drive Cycle, constant, signal editor) and I have tuned the speed and current loops accordingly.
The Sample Time
Control Sample time (TSc) = Tsw/250 (Switching time over 250 samples per switching time)
PWM Sample time (TS) = 1/(10*fsw)
The motor is seem to follow the reference speed correctly, however the generated agte signals are seem to sampled sine wave, between 1 and -1.
The voltage (Phase-phase) and (Phase-to-Nuetral) waveform is quite unusual (my input is 48V)
Although the control loops are tuned and there is very low oscillation in the controlled output, however the phase current has hige distortion which I tried to suppress via low-pass filter.
When I put the parameterized semicondcutor instead of idela converter, the gate are signal are not even generating. A gate driver is used to provide PWM signal form the controller to the N-channel MOSFET.
I am attaching few screenshots and my model, if any could validate the model and provide the guidance regarding aforementioned.
Thank You!Hello Everyone,
I have been trying to follow the example model "PMSM Velocity Control" where my final objective is to replace the idela converter with parameterized discrete devices. For now, I am using ideal converter, with different reference speed (Drive Cycle, constant, signal editor) and I have tuned the speed and current loops accordingly.
The Sample Time
Control Sample time (TSc) = Tsw/250 (Switching time over 250 samples per switching time)
PWM Sample time (TS) = 1/(10*fsw)
The motor is seem to follow the reference speed correctly, however the generated agte signals are seem to sampled sine wave, between 1 and -1.
The voltage (Phase-phase) and (Phase-to-Nuetral) waveform is quite unusual (my input is 48V)
Although the control loops are tuned and there is very low oscillation in the controlled output, however the phase current has hige distortion which I tried to suppress via low-pass filter.
When I put the parameterized semicondcutor instead of idela converter, the gate are signal are not even generating. A gate driver is used to provide PWM signal form the controller to the N-channel MOSFET.
I am attaching few screenshots and my model, if any could validate the model and provide the guidance regarding aforementioned.
Thank You! Hello Everyone,
I have been trying to follow the example model "PMSM Velocity Control" where my final objective is to replace the idela converter with parameterized discrete devices. For now, I am using ideal converter, with different reference speed (Drive Cycle, constant, signal editor) and I have tuned the speed and current loops accordingly.
The Sample Time
Control Sample time (TSc) = Tsw/250 (Switching time over 250 samples per switching time)
PWM Sample time (TS) = 1/(10*fsw)
The motor is seem to follow the reference speed correctly, however the generated agte signals are seem to sampled sine wave, between 1 and -1.
The voltage (Phase-phase) and (Phase-to-Nuetral) waveform is quite unusual (my input is 48V)
Although the control loops are tuned and there is very low oscillation in the controlled output, however the phase current has hige distortion which I tried to suppress via low-pass filter.
When I put the parameterized semicondcutor instead of idela converter, the gate are signal are not even generating. A gate driver is used to provide PWM signal form the controller to the N-channel MOSFET.
I am attaching few screenshots and my model, if any could validate the model and provide the guidance regarding aforementioned.
Thank You! simscape, power_electronics_control MATLAB Answers — New Questions
fsolve with multiple parameters
I have defined a function with 3 inputs that finds the trajectory of a baseball using Euler’s method.
The three inputs are the initial velocity, intial angle, and flag which determines the return.
What I mean by flag is that if it is 0, the function returns the height of the baseball over home plate.
If flag is 1, the function returns the entire trajectory of the baseball (A matrix containing index, position (x,y), and time).
function ret = xyt(v0,theta0,flag)
m = 0.328;
k = 0.01;
g = 32.174;
xhome = 60.5;
spin = 0;
Vx = v0*cosd(theta0);
Vy = v0*sind(theta0);
Traj = [0 0.0 8 0];
for i = 1:(xhome*2)
dVx = (-k/m)*sqrt((Vx.^2)+(Vy.^2));
dVy = ((-k/m)*Vy*sqrt((Vx.^2)+(Vy.^2))-g+(spin/m))/Vx;
Traj(i+1,1) = i;
Traj(i+1,2) = 0.5*i;
Traj(i+1,3) = (0.5*(Vy/Vx))+Traj(i,3);
Traj(i+1,4) = (0.5/Vx)+Traj(i,4);
Vx = Vx+dVx*0.5;
Vy = Vy+dVy*0.5;
end
if flag == 0
ret = Traj((2*xhome)+1,3);
else
ret = Traj;
end
end
However, I want to try and find the initial angle given that the initial velocity is 147 and flag is 0 and the return is 3 (3 feet above homeplate).
I tried this code
v0 = 147;
x0 = 3;
flag = 0;
[x,fval] = fsolve(@(theta) xyt(v0,theta,flag), x0);
However, the return of this
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
The return is no where near the expected answer which should be around 9.2. Instead the return for x is 6.1420 and the return for fval is extremely small.
Please advise what to do. I don’t fully understand the syntax of fsolve with user defined functions. Thank you.I have defined a function with 3 inputs that finds the trajectory of a baseball using Euler’s method.
The three inputs are the initial velocity, intial angle, and flag which determines the return.
What I mean by flag is that if it is 0, the function returns the height of the baseball over home plate.
If flag is 1, the function returns the entire trajectory of the baseball (A matrix containing index, position (x,y), and time).
function ret = xyt(v0,theta0,flag)
m = 0.328;
k = 0.01;
g = 32.174;
xhome = 60.5;
spin = 0;
Vx = v0*cosd(theta0);
Vy = v0*sind(theta0);
Traj = [0 0.0 8 0];
for i = 1:(xhome*2)
dVx = (-k/m)*sqrt((Vx.^2)+(Vy.^2));
dVy = ((-k/m)*Vy*sqrt((Vx.^2)+(Vy.^2))-g+(spin/m))/Vx;
Traj(i+1,1) = i;
Traj(i+1,2) = 0.5*i;
Traj(i+1,3) = (0.5*(Vy/Vx))+Traj(i,3);
Traj(i+1,4) = (0.5/Vx)+Traj(i,4);
Vx = Vx+dVx*0.5;
Vy = Vy+dVy*0.5;
end
if flag == 0
ret = Traj((2*xhome)+1,3);
else
ret = Traj;
end
end
However, I want to try and find the initial angle given that the initial velocity is 147 and flag is 0 and the return is 3 (3 feet above homeplate).
I tried this code
v0 = 147;
x0 = 3;
flag = 0;
[x,fval] = fsolve(@(theta) xyt(v0,theta,flag), x0);
However, the return of this
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
The return is no where near the expected answer which should be around 9.2. Instead the return for x is 6.1420 and the return for fval is extremely small.
Please advise what to do. I don’t fully understand the syntax of fsolve with user defined functions. Thank you. I have defined a function with 3 inputs that finds the trajectory of a baseball using Euler’s method.
The three inputs are the initial velocity, intial angle, and flag which determines the return.
What I mean by flag is that if it is 0, the function returns the height of the baseball over home plate.
If flag is 1, the function returns the entire trajectory of the baseball (A matrix containing index, position (x,y), and time).
function ret = xyt(v0,theta0,flag)
m = 0.328;
k = 0.01;
g = 32.174;
xhome = 60.5;
spin = 0;
Vx = v0*cosd(theta0);
Vy = v0*sind(theta0);
Traj = [0 0.0 8 0];
for i = 1:(xhome*2)
dVx = (-k/m)*sqrt((Vx.^2)+(Vy.^2));
dVy = ((-k/m)*Vy*sqrt((Vx.^2)+(Vy.^2))-g+(spin/m))/Vx;
Traj(i+1,1) = i;
Traj(i+1,2) = 0.5*i;
Traj(i+1,3) = (0.5*(Vy/Vx))+Traj(i,3);
Traj(i+1,4) = (0.5/Vx)+Traj(i,4);
Vx = Vx+dVx*0.5;
Vy = Vy+dVy*0.5;
end
if flag == 0
ret = Traj((2*xhome)+1,3);
else
ret = Traj;
end
end
However, I want to try and find the initial angle given that the initial velocity is 147 and flag is 0 and the return is 3 (3 feet above homeplate).
I tried this code
v0 = 147;
x0 = 3;
flag = 0;
[x,fval] = fsolve(@(theta) xyt(v0,theta,flag), x0);
However, the return of this
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
The return is no where near the expected answer which should be around 9.2. Instead the return for x is 6.1420 and the return for fval is extremely small.
Please advise what to do. I don’t fully understand the syntax of fsolve with user defined functions. Thank you. fsolve, input, function, embedded matlab function MATLAB Answers — New Questions
How to use PID controller from Control System TB in Matlab function of Stateflow?
I want to use PID controller in Stateflow. I made two options (above): Simulink function and Simulink state.
How to use Matlab function, PID from Control System toolbox? This PID is object like transfer function, and I need time series.I want to use PID controller in Stateflow. I made two options (above): Simulink function and Simulink state.
How to use Matlab function, PID from Control System toolbox? This PID is object like transfer function, and I need time series. I want to use PID controller in Stateflow. I made two options (above): Simulink function and Simulink state.
How to use Matlab function, PID from Control System toolbox? This PID is object like transfer function, and I need time series. pid, stateflow, embedded matlab function MATLAB Answers — New Questions
dlhdl.buildProcessor Problem
Hi
I am working on the subject that generate bitstream file.
I read matworks helper but it doesn’t work. I have a so simple question because I’m new this subject.
I have attached a screenshot of the error.
Could you help me please? What is the wrong?
Best Regards,Hi
I am working on the subject that generate bitstream file.
I read matworks helper but it doesn’t work. I have a so simple question because I’m new this subject.
I have attached a screenshot of the error.
Could you help me please? What is the wrong?
Best Regards, Hi
I am working on the subject that generate bitstream file.
I read matworks helper but it doesn’t work. I have a so simple question because I’m new this subject.
I have attached a screenshot of the error.
Could you help me please? What is the wrong?
Best Regards, dlhdl MATLAB Answers — New Questions
why i can not rename the load flow bus block in simulink?
load flow bus blockload flow bus block load flow bus block load flow bus MATLAB Answers — New Questions
Multiframe Image arrays 4-D DICOM
Hello!
I need to work with collections of images related by time or view, such as magnetic resonance imaging (MRI) slices or movie frames. (attached)
I need to get the ROI of the image but in different times.
So, I have a multi frame image (4D uint16 DICOM) with 36 frames and I also have my code but it only shows the sum of the 36 frames…
P.S. It is an image of a 3D SPECT scan I need to check the values of ROI in different times to get the intensities/ countings, so that I can get the curve Activity vs Time.
Could please somebody help me?
%%OPEN MULTI FRAME
image_data =dicomread(‘FLOW001_DS.dcm’);
sum2d = sum(image_data,4);
sum2d=256-sum2d;
imshow(sum2d,[])
%Otsu to the generated image
A=otsu(sum2d,2); % testar com outros valores (3 por exemplo);
%Cany countour to select the ROI
BW1 = edge(A,’Canny’);
imshow(BW1)
%Sum original image+ cany ;
sumf=imadd(sum2d,im2double(BW1).*250);
imshow(sumf,[])
imagesc(sumf)
%binary image
umbral=graythresh(sumf);
imag_bw=im2bw(sumf,umbral);
imshow(imag_bw)
%object identification in image
if true
% code
end
imag_bw_label=bwlabel(imag_bw);
imshow(label2rgb(imag_bw_label));
propriedades= regionprops(imag_bw_label);Hello!
I need to work with collections of images related by time or view, such as magnetic resonance imaging (MRI) slices or movie frames. (attached)
I need to get the ROI of the image but in different times.
So, I have a multi frame image (4D uint16 DICOM) with 36 frames and I also have my code but it only shows the sum of the 36 frames…
P.S. It is an image of a 3D SPECT scan I need to check the values of ROI in different times to get the intensities/ countings, so that I can get the curve Activity vs Time.
Could please somebody help me?
%%OPEN MULTI FRAME
image_data =dicomread(‘FLOW001_DS.dcm’);
sum2d = sum(image_data,4);
sum2d=256-sum2d;
imshow(sum2d,[])
%Otsu to the generated image
A=otsu(sum2d,2); % testar com outros valores (3 por exemplo);
%Cany countour to select the ROI
BW1 = edge(A,’Canny’);
imshow(BW1)
%Sum original image+ cany ;
sumf=imadd(sum2d,im2double(BW1).*250);
imshow(sumf,[])
imagesc(sumf)
%binary image
umbral=graythresh(sumf);
imag_bw=im2bw(sumf,umbral);
imshow(imag_bw)
%object identification in image
if true
% code
end
imag_bw_label=bwlabel(imag_bw);
imshow(label2rgb(imag_bw_label));
propriedades= regionprops(imag_bw_label); Hello!
I need to work with collections of images related by time or view, such as magnetic resonance imaging (MRI) slices or movie frames. (attached)
I need to get the ROI of the image but in different times.
So, I have a multi frame image (4D uint16 DICOM) with 36 frames and I also have my code but it only shows the sum of the 36 frames…
P.S. It is an image of a 3D SPECT scan I need to check the values of ROI in different times to get the intensities/ countings, so that I can get the curve Activity vs Time.
Could please somebody help me?
%%OPEN MULTI FRAME
image_data =dicomread(‘FLOW001_DS.dcm’);
sum2d = sum(image_data,4);
sum2d=256-sum2d;
imshow(sum2d,[])
%Otsu to the generated image
A=otsu(sum2d,2); % testar com outros valores (3 por exemplo);
%Cany countour to select the ROI
BW1 = edge(A,’Canny’);
imshow(BW1)
%Sum original image+ cany ;
sumf=imadd(sum2d,im2double(BW1).*250);
imshow(sumf,[])
imagesc(sumf)
%binary image
umbral=graythresh(sumf);
imag_bw=im2bw(sumf,umbral);
imshow(imag_bw)
%object identification in image
if true
% code
end
imag_bw_label=bwlabel(imag_bw);
imshow(label2rgb(imag_bw_label));
propriedades= regionprops(imag_bw_label); multi frame, dynamic, time MATLAB Answers — New Questions
Algorithm used in los2 function
I am using the los2() function to evaluate line-of-sight between two points. The function indicates that line-of-sight is lost when the elevation of the second point in the AER frame centered on the first point is greater than zero; point values corresponding to an elevation of zero are indicated as being below the horizon.
As far as I understand, all points at or above zero elevation at a particular location should be within line-of-sight from that location; however, this does not appear to agree with the results from los2. Is my understanding of the LOS calculation inaccurate or am I missing something about the way los2 performs its calculation?I am using the los2() function to evaluate line-of-sight between two points. The function indicates that line-of-sight is lost when the elevation of the second point in the AER frame centered on the first point is greater than zero; point values corresponding to an elevation of zero are indicated as being below the horizon.
As far as I understand, all points at or above zero elevation at a particular location should be within line-of-sight from that location; however, this does not appear to agree with the results from los2. Is my understanding of the LOS calculation inaccurate or am I missing something about the way los2 performs its calculation? I am using the los2() function to evaluate line-of-sight between two points. The function indicates that line-of-sight is lost when the elevation of the second point in the AER frame centered on the first point is greater than zero; point values corresponding to an elevation of zero are indicated as being below the horizon.
As far as I understand, all points at or above zero elevation at a particular location should be within line-of-sight from that location; however, this does not appear to agree with the results from los2. Is my understanding of the LOS calculation inaccurate or am I missing something about the way los2 performs its calculation? mapping toolbox, line of sight, los2, earth curvature MATLAB Answers — New Questions
Get only block name from get() function
How can I get only the name of the block without the port number?
I have this line:
blockname_and_portnum = get(line_connection_handler,’SourcePort’);
and it gives me:
Step:1
but I need only Step. I want to get this without any extractBefore functions for code optimization. It is possible to get only block name from the function get()?How can I get only the name of the block without the port number?
I have this line:
blockname_and_portnum = get(line_connection_handler,’SourcePort’);
and it gives me:
Step:1
but I need only Step. I want to get this without any extractBefore functions for code optimization. It is possible to get only block name from the function get()? How can I get only the name of the block without the port number?
I have this line:
blockname_and_portnum = get(line_connection_handler,’SourcePort’);
and it gives me:
Step:1
but I need only Step. I want to get this without any extractBefore functions for code optimization. It is possible to get only block name from the function get()? simulink, get, matlab MATLAB Answers — New Questions
I am using roots command for a complicated equation to find out the roots but in return it is giving me roots command in it . How can I solve this?
I am getting this
root(23*a^6*z^3 – 1075392*a^6*z^2 – 720*a^8*z^2 – 793497600*a^4*z^2 + 17471324160*a^6*z + 17031168*a^8*z – 27648*a^10*z + 4019957268480*a^4*z + 248656057860096*a^2*z + 1111306272768*a^8 + 1117403052244992*a^4 + 12586608230400*a^6 + 1353646080*a^10 + 442368*a^12 – 781755859725189120*a^2 + 961852771978444800, z, 1)^(1/2)
when I used the command
Det=collect(det(A),Rh);
Dc=coeffs(Det,Rh,"All");
Dr=roots(Dc);
Rh and a are my variables and I want the value of Rh in a.
I have tried the command simplify also.I am getting this
root(23*a^6*z^3 – 1075392*a^6*z^2 – 720*a^8*z^2 – 793497600*a^4*z^2 + 17471324160*a^6*z + 17031168*a^8*z – 27648*a^10*z + 4019957268480*a^4*z + 248656057860096*a^2*z + 1111306272768*a^8 + 1117403052244992*a^4 + 12586608230400*a^6 + 1353646080*a^10 + 442368*a^12 – 781755859725189120*a^2 + 961852771978444800, z, 1)^(1/2)
when I used the command
Det=collect(det(A),Rh);
Dc=coeffs(Det,Rh,"All");
Dr=roots(Dc);
Rh and a are my variables and I want the value of Rh in a.
I have tried the command simplify also. I am getting this
root(23*a^6*z^3 – 1075392*a^6*z^2 – 720*a^8*z^2 – 793497600*a^4*z^2 + 17471324160*a^6*z + 17031168*a^8*z – 27648*a^10*z + 4019957268480*a^4*z + 248656057860096*a^2*z + 1111306272768*a^8 + 1117403052244992*a^4 + 12586608230400*a^6 + 1353646080*a^10 + 442368*a^12 – 781755859725189120*a^2 + 961852771978444800, z, 1)^(1/2)
when I used the command
Det=collect(det(A),Rh);
Dc=coeffs(Det,Rh,"All");
Dr=roots(Dc);
Rh and a are my variables and I want the value of Rh in a.
I have tried the command simplify also. roots, simplif MATLAB Answers — New Questions
Function ‘boundary’ not supported for code generation. How to solve this?
Function boundary(), which is used to get the boundary of a set of points, does not support code generation. When I use coder to generate C++ code, error occurs. How to solve this problem?Function boundary(), which is used to get the boundary of a set of points, does not support code generation. When I use coder to generate C++ code, error occurs. How to solve this problem? Function boundary(), which is used to get the boundary of a set of points, does not support code generation. When I use coder to generate C++ code, error occurs. How to solve this problem? boundary, code generation MATLAB Answers — New Questions
Problem to converge a loop in Simulink
Hello , I want to simulate a close circuit that consist on a grinding mill next to hydrocyclon and have the following problem with the code that joins two flows tabla1 of dimension 11×5 and TablaFlujo1 of dimension 2×3 are from the input flow, while tabla2 of dimension 11×5 and TablaFlow2 of dimension 2×3 are from the recirculated flow(very important to remark because it causes a loop) from the whole process and in this code they are added together to form a single flow named TablaGranulometrica and TablaFlujo . i tried to initialize the recirculated flow with the desired size,and so the output stream ,but pops a error instead : "Block ”granulometria4/Subsystem3/MATLAB Function5” does not fully set the dimensions of output ‘TablaFlujo’."
I will give attach a screenshot :
I really dont know how to make it converge or at least give an initial condition so it start running . Below is the function script , will also attach the full file. thanks in advance.
function [TablaGranulometrica, TablaFlujo, total,convergencia] = fcn(tabla1, TablaFlujo1, tabla2, TablaFlujo2,epsilon)
if size(tabla2)~=size(tabla2)
tabla2 = tabla1; % Inicializa tabla2 como matriz de ceros del mismo tamaño que tabla1
end
if size(TablaFlujo1)~=size(TablaFlujo2)
TablaFlujo2 = (TablaFlujo1); % Inicializa TablaFlujo2 como matriz de ceros del mismo tamaño que TablaFlujo1
end
% Tabla Granulométrica
TablaGranulometrica = tabla1;
TablaGranulometrica(:,2) = tabla1(:,2) + tabla2(:,2);
total = sum(TablaGranulometrica(:, 2));
TablaGranulometrica(:, 3) = (TablaGranulometrica(:, 2) / total) * 100;
TablaGranulometrica(:, 4) = cumsum(TablaGranulometrica(:, 3));
TablaGranulometrica(:, 5) = 100 – TablaGranulometrica(:, 4);
% Tabla de Flujo
TablaFlujo = size(2, 3); % Dimensiones fijas [2×3]
TablaFlujo = zeros(size(TablaFlujo1)); % Inicializa la salida
TablaFlujo(1,1) = TablaFlujo1(1,1) + TablaFlujo2(1,1);
TablaFlujo(2,3) = TablaFlujo1(2,3) + TablaFlujo2(2,3);
TablaFlujo(2,2) = (TablaFlujo(1,1) / 2.45) + TablaFlujo(2,3);
TablaFlujo(2,1) = 100 * TablaFlujo(1,1) / (TablaFlujo(1,1) + TablaFlujo(2,3));
TablaFlujo(1,2) = 100 * (TablaFlujo(1,1)) / (TablaFlujo(2,1) * TablaFlujo(2,2));
TablaFlujo(1,3) = 2.45;
% Cálculo final de total
total = sum(TablaGranulometrica(:,2)) * 24;
error_tabla = max(abs(tabla1(:,2) – tabla2(:,2)));
error_flujo = max(abs(TablaFlujo1(:,1) – TablaFlujo2(:,1)));
convergencia = (error_tabla < epsilon) && (error_flujo < epsilon);
endHello , I want to simulate a close circuit that consist on a grinding mill next to hydrocyclon and have the following problem with the code that joins two flows tabla1 of dimension 11×5 and TablaFlujo1 of dimension 2×3 are from the input flow, while tabla2 of dimension 11×5 and TablaFlow2 of dimension 2×3 are from the recirculated flow(very important to remark because it causes a loop) from the whole process and in this code they are added together to form a single flow named TablaGranulometrica and TablaFlujo . i tried to initialize the recirculated flow with the desired size,and so the output stream ,but pops a error instead : "Block ”granulometria4/Subsystem3/MATLAB Function5” does not fully set the dimensions of output ‘TablaFlujo’."
I will give attach a screenshot :
I really dont know how to make it converge or at least give an initial condition so it start running . Below is the function script , will also attach the full file. thanks in advance.
function [TablaGranulometrica, TablaFlujo, total,convergencia] = fcn(tabla1, TablaFlujo1, tabla2, TablaFlujo2,epsilon)
if size(tabla2)~=size(tabla2)
tabla2 = tabla1; % Inicializa tabla2 como matriz de ceros del mismo tamaño que tabla1
end
if size(TablaFlujo1)~=size(TablaFlujo2)
TablaFlujo2 = (TablaFlujo1); % Inicializa TablaFlujo2 como matriz de ceros del mismo tamaño que TablaFlujo1
end
% Tabla Granulométrica
TablaGranulometrica = tabla1;
TablaGranulometrica(:,2) = tabla1(:,2) + tabla2(:,2);
total = sum(TablaGranulometrica(:, 2));
TablaGranulometrica(:, 3) = (TablaGranulometrica(:, 2) / total) * 100;
TablaGranulometrica(:, 4) = cumsum(TablaGranulometrica(:, 3));
TablaGranulometrica(:, 5) = 100 – TablaGranulometrica(:, 4);
% Tabla de Flujo
TablaFlujo = size(2, 3); % Dimensiones fijas [2×3]
TablaFlujo = zeros(size(TablaFlujo1)); % Inicializa la salida
TablaFlujo(1,1) = TablaFlujo1(1,1) + TablaFlujo2(1,1);
TablaFlujo(2,3) = TablaFlujo1(2,3) + TablaFlujo2(2,3);
TablaFlujo(2,2) = (TablaFlujo(1,1) / 2.45) + TablaFlujo(2,3);
TablaFlujo(2,1) = 100 * TablaFlujo(1,1) / (TablaFlujo(1,1) + TablaFlujo(2,3));
TablaFlujo(1,2) = 100 * (TablaFlujo(1,1)) / (TablaFlujo(2,1) * TablaFlujo(2,2));
TablaFlujo(1,3) = 2.45;
% Cálculo final de total
total = sum(TablaGranulometrica(:,2)) * 24;
error_tabla = max(abs(tabla1(:,2) – tabla2(:,2)));
error_flujo = max(abs(TablaFlujo1(:,1) – TablaFlujo2(:,1)));
convergencia = (error_tabla < epsilon) && (error_flujo < epsilon);
end Hello , I want to simulate a close circuit that consist on a grinding mill next to hydrocyclon and have the following problem with the code that joins two flows tabla1 of dimension 11×5 and TablaFlujo1 of dimension 2×3 are from the input flow, while tabla2 of dimension 11×5 and TablaFlow2 of dimension 2×3 are from the recirculated flow(very important to remark because it causes a loop) from the whole process and in this code they are added together to form a single flow named TablaGranulometrica and TablaFlujo . i tried to initialize the recirculated flow with the desired size,and so the output stream ,but pops a error instead : "Block ”granulometria4/Subsystem3/MATLAB Function5” does not fully set the dimensions of output ‘TablaFlujo’."
I will give attach a screenshot :
I really dont know how to make it converge or at least give an initial condition so it start running . Below is the function script , will also attach the full file. thanks in advance.
function [TablaGranulometrica, TablaFlujo, total,convergencia] = fcn(tabla1, TablaFlujo1, tabla2, TablaFlujo2,epsilon)
if size(tabla2)~=size(tabla2)
tabla2 = tabla1; % Inicializa tabla2 como matriz de ceros del mismo tamaño que tabla1
end
if size(TablaFlujo1)~=size(TablaFlujo2)
TablaFlujo2 = (TablaFlujo1); % Inicializa TablaFlujo2 como matriz de ceros del mismo tamaño que TablaFlujo1
end
% Tabla Granulométrica
TablaGranulometrica = tabla1;
TablaGranulometrica(:,2) = tabla1(:,2) + tabla2(:,2);
total = sum(TablaGranulometrica(:, 2));
TablaGranulometrica(:, 3) = (TablaGranulometrica(:, 2) / total) * 100;
TablaGranulometrica(:, 4) = cumsum(TablaGranulometrica(:, 3));
TablaGranulometrica(:, 5) = 100 – TablaGranulometrica(:, 4);
% Tabla de Flujo
TablaFlujo = size(2, 3); % Dimensiones fijas [2×3]
TablaFlujo = zeros(size(TablaFlujo1)); % Inicializa la salida
TablaFlujo(1,1) = TablaFlujo1(1,1) + TablaFlujo2(1,1);
TablaFlujo(2,3) = TablaFlujo1(2,3) + TablaFlujo2(2,3);
TablaFlujo(2,2) = (TablaFlujo(1,1) / 2.45) + TablaFlujo(2,3);
TablaFlujo(2,1) = 100 * TablaFlujo(1,1) / (TablaFlujo(1,1) + TablaFlujo(2,3));
TablaFlujo(1,2) = 100 * (TablaFlujo(1,1)) / (TablaFlujo(2,1) * TablaFlujo(2,2));
TablaFlujo(1,3) = 2.45;
% Cálculo final de total
total = sum(TablaGranulometrica(:,2)) * 24;
error_tabla = max(abs(tabla1(:,2) – tabla2(:,2)));
error_flujo = max(abs(TablaFlujo1(:,1) – TablaFlujo2(:,1)));
convergencia = (error_tabla < epsilon) && (error_flujo < epsilon);
end simulink, loop, converge MATLAB Answers — New Questions
How can I generate the setup of AC sweep for AC Voltage source in either Matlab or simulink?
How can I generate the AC sweep for AC Voltage source? To simulate analog filter such as Low pass filter, high pass filter or EMI filter, we need AC sweep setup to run simulation. These AC Analysis includes Type of Sweep (Decade), Number of points per decade (100), Start frequency (10), Stop Frequency (100MEG). How can I generate these setup of the AC sweep for AC Voltage source in either Matlab or simulink?How can I generate the AC sweep for AC Voltage source? To simulate analog filter such as Low pass filter, high pass filter or EMI filter, we need AC sweep setup to run simulation. These AC Analysis includes Type of Sweep (Decade), Number of points per decade (100), Start frequency (10), Stop Frequency (100MEG). How can I generate these setup of the AC sweep for AC Voltage source in either Matlab or simulink? How can I generate the AC sweep for AC Voltage source? To simulate analog filter such as Low pass filter, high pass filter or EMI filter, we need AC sweep setup to run simulation. These AC Analysis includes Type of Sweep (Decade), Number of points per decade (100), Start frequency (10), Stop Frequency (100MEG). How can I generate these setup of the AC sweep for AC Voltage source in either Matlab or simulink? simulink 2014b MATLAB Answers — New Questions
dq-to-abc block does not work when the input is from three-phase measurement block
The dq-to-abc blocks give a constant Vd and Vq when the input block (60Hz) is used is a three phase sine wave generator (Electrical/Specialised Power System). However, when the input is from a three phase measurement block which measure a balanced three phase system the Vd and Vq is a sinusoidal wave with frequency 120Hz and same magnitude as the phase magnitude of the wave.
With measurement block
With Three phase wave generatorThe dq-to-abc blocks give a constant Vd and Vq when the input block (60Hz) is used is a three phase sine wave generator (Electrical/Specialised Power System). However, when the input is from a three phase measurement block which measure a balanced three phase system the Vd and Vq is a sinusoidal wave with frequency 120Hz and same magnitude as the phase magnitude of the wave.
With measurement block
With Three phase wave generator The dq-to-abc blocks give a constant Vd and Vq when the input block (60Hz) is used is a three phase sine wave generator (Electrical/Specialised Power System). However, when the input is from a three phase measurement block which measure a balanced three phase system the Vd and Vq is a sinusoidal wave with frequency 120Hz and same magnitude as the phase magnitude of the wave.
With measurement block
With Three phase wave generator #dq-abc #clarke-park MATLAB Answers — New Questions
define an objective function with user defined number of variables in fminunc()
Suppose I want to define the following function in matlab which returns the output of fminunc(). The problem here is the number of variables depends on the user input. How do I define the objective function fun() such that it automatically adapts to the number of variables.
function xmin = problem(n)
if n == 1
fun = @(x) x^2+2*x+3;
xmin = fminunc(fun,1);
end
if n == 2
fun = @(x) x(1)^2+x(2)^2+2*(x(1)+x(2))+3;
xmin = fminunc(fun,[1 0]);
end
if n == 3
fun = @(x) x(1)^2+x(2)^2+x(3)^2+2*(x(1)+x(2)+x(3))+3;
xmin = fminunc(fun,[1 0 0]);
end
% n is the number of variables for fun.
% the list goes on. n==4, n==5,…
endSuppose I want to define the following function in matlab which returns the output of fminunc(). The problem here is the number of variables depends on the user input. How do I define the objective function fun() such that it automatically adapts to the number of variables.
function xmin = problem(n)
if n == 1
fun = @(x) x^2+2*x+3;
xmin = fminunc(fun,1);
end
if n == 2
fun = @(x) x(1)^2+x(2)^2+2*(x(1)+x(2))+3;
xmin = fminunc(fun,[1 0]);
end
if n == 3
fun = @(x) x(1)^2+x(2)^2+x(3)^2+2*(x(1)+x(2)+x(3))+3;
xmin = fminunc(fun,[1 0 0]);
end
% n is the number of variables for fun.
% the list goes on. n==4, n==5,…
end Suppose I want to define the following function in matlab which returns the output of fminunc(). The problem here is the number of variables depends on the user input. How do I define the objective function fun() such that it automatically adapts to the number of variables.
function xmin = problem(n)
if n == 1
fun = @(x) x^2+2*x+3;
xmin = fminunc(fun,1);
end
if n == 2
fun = @(x) x(1)^2+x(2)^2+2*(x(1)+x(2))+3;
xmin = fminunc(fun,[1 0]);
end
if n == 3
fun = @(x) x(1)^2+x(2)^2+x(3)^2+2*(x(1)+x(2)+x(3))+3;
xmin = fminunc(fun,[1 0 0]);
end
% n is the number of variables for fun.
% the list goes on. n==4, n==5,…
end fminunc MATLAB Answers — New Questions