Please help me to look at the code below. Thx

I want to get the max and min value of the equation, using the last three lines of code. BuI I don't know what's wrong with the issue.

 Accepted Answer

Change the name of the output variable on line 15. When a variable named min exists you will not be able to call the min function.
In fact if you're looking for the first instance of the minimum value don't use find. Call min with two output arguments.

6 Comments

OK, but it is still not work...
Can anyone answer this question, plz
Clear your workspace. The variable min still exists.
Once you do, it works just fine. I've cleaned the last 3 lines of your code a little.
x=0:0.001:5;
f12 = 8.*(x-pi).^2./((x-pi).^2+1).^3-2./((x-pi).^2+1).^2;
figure
plot(x,f12)
[f12min,index] = min(f12)
f12min = -2.0000
index = 3143
xmin = x(index)
xmin = 3.1420
It seems like right. why I am getting another error, I am going to collapsed.
I have checked lots of times, I don't have any min variables in my workspace, but it still not works
It works thank you so much

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!