Find optimum value to fit with the answer

조회 수: 2 (최근 30일)
Ali Tawfik
Ali Tawfik 2020년 8월 25일
댓글: Ali Tawfik 2020년 8월 26일
Hi all,
I would like to know how to find an optimium value to reach or fit with the final result even if I change other variables as shown:
clear all;
clc;
x=10; y=20;
k=x+y;
f=20; m=10;
t=1; % I need to find the optimum value of t which should be in this case 41
final=k+f+m+t
if final<100
disp('ok')
else
disp('no')
end
  댓글 수: 2
Alan Stevens
Alan Stevens 2020년 8월 25일
편집: Alan Stevens 2020년 8월 25일
In the case you show, if t is 41 then final would be 101, which seems to exceed your desired value of 100.
Rik
Rik 2020년 8월 25일
Don't use clear all. It clears all functions that were loaded to memory, which causes everything to be slower. If you want to clear the variables in a debugging context you can use clear or clearvars. Outside of debugging you should use functions to keep your workspace clean.

댓글을 달려면 로그인하십시오.

채택된 답변

esat gulhan
esat gulhan 2020년 8월 25일
편집: esat gulhan 2020년 8월 25일
Can it be like this, if you want to find value if final>100
clc;clear;
syms x y t k f m
x=10; y=20;
k=x+y;
f=20; m=10;
final=k+f+m+t>=100
t=solve(final,t)
of if you want to find value if final=100
clc;clear;
syms x y t k f m
x=10; y=20;
k=x+y;
f=20; m=10;
final=k+f+m+t==100
t=solve(final,t)
  댓글 수: 1
Ali Tawfik
Ali Tawfik 2020년 8월 26일
@Esat,
Thanks for your prompt reply. Would you mind having look into my new question , as I need help !!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by