find the maximum value of a function
古いコメントを表示
It's given that y(x) = log(14*x+30) on [a b]
how can I find the maximum value of diff(y,2) for every a and b which is satisfied 14*x + 30 > 0 ?
2 件のコメント
John D'Errico
2018 年 11 月 19 日
What have you tried? If nothing, why not, on what is surely homework? If you want help, then make an effort. Show what you have tried. Then explain wht went wrong, and where you think you need to go next.
Ken Le
2018 年 11 月 19 日
採用された回答
その他の回答 (3 件)
1 件のコメント
Andrew Robertson
2019 年 10 月 29 日
編集済み: Andrew Robertson
2019 年 10 月 29 日
0 投票
Discraceful are all the answers!, he may have not been specific in the details of his question, and no one answered, or even came close to the proper answer!.
I believe he is having the same issue i am, I have a complex sum, and when I do "result = max(MyFunction)",
the answer i get is the function with the inputs into it to give the maximum result!, what the f%^k! who wrote this s@#T!?
I wanted the maximum result as a number, not a function, if i had asked for the result of a function, I would have looked for a code call to do so!.
So my problem, the same as the origianl ask, is, how do i get a number of a max call, not the garbage I am getting now?
And a 2nd question, the figure matlab found to put into the function to get the max(and minimum) how do i extract that?
Andrew
P.S. I feel greatly elated to know I got a badge for this comment!
3 件のコメント
Andrew Robertson
2019 年 10 月 29 日
As I found an answer to this, I will provide it!
if a max(something) is returning not a number, but a function or something similar, like "sin(34) + 56" then you do this:-
MyResult = eval(max(something));
BUT BE WARNED, eval in the programing world is dangerous, because it takes whatever is in "something" and attempts to run it!, even if it is crash/malious script.
This will get you the actual number your looking for!.
Next part, how to extract the "34" out of the calculated result, that, is done through string manipulation, i.e. solit the string at the "(" like as follows, "split(something, '(')" and you will get the array, leave the semi-colan ";" of the end and matlab will print the array, make sure you have the correct array position to do the next split on the ")" like as follows "split(MyChars[2], ')')"
Easy eh!?, not exactly, what is returned may not be a string to start with, and it might have to be converted via the use of char(something),
Andrew Robertson
2019 年 10 月 29 日
編集済み: Andrew Robertson
2019 年 10 月 29 日
I suppose he clicked accept to an answer, as, he not knowing much about matlab thought (likely incorrectly) he had got the best and correct answer!.
He asked for a maximum value!, a number, and he now has the tools to get it,
I did not answer his 2nd part, being to satisfy an equation, but that is the easy part, just start x at x > -30/14 or start x at -30/14 + 0.00001 that is, according to his equation!
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
