please I want to know if it is possible to write an equation containing a variable before writing down the values. e.g V = a+3, before writing down the value of a.

3 件のコメント

Stephen23
Stephen23 2019 年 12 月 2 日
編集済み: Stephen23 2019 年 12 月 2 日
Numeric computations: yes when you define its as a function input, otherwise no.
Symbolic calculations: yes.
Which do you want to do?
henry tochukwu
henry tochukwu 2019 年 12 月 2 日
symbolic.
with an example please
thanks
henry tochukwu
henry tochukwu 2019 年 12 月 2 日
I was given an assignment with the equation f = 5(t-32)/9 and was asked to insert the equation before assigning a value to the variable t.
i.e f = 5(t-32)/9
then assign a value to t, but it is not working
I want to know if there any process involved

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2019 年 12 月 2 日

1 投票

f = @(t) 5*(t-32)/9
or
syms t
f = 5*(t-32)/9

9 件のコメント

henry tochukwu
henry tochukwu 2019 年 12 月 2 日
when i used the first step this was the result
f = @(t) 5*(t-32)/9
f =
function_handle with value:
@(t)5*(t-32)/9
with function_handle on blue tag
what other step do I need to take in order to now add a value to t in order to get the final answer for f.
henry tochukwu
henry tochukwu 2019 年 12 月 2 日
please I need the answer urgently.
I will greatly appreciate if i can get the answer before the next 12hrs.
Thanks.
KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 12 月 2 日
編集済み: KALYAN ACHARJYA 2019 年 12 月 2 日
There also you have define t before either. as sybolic variable t or variable @(t) then_function. But yes later you can pass the t value to the solved expression
Steven Lord
Steven Lord 2019 年 12 月 2 日
Define the anonymous function first.
f = @(t) 5*(t-32)/9
Then call f with numeric values for t.
f([-40 0 32 98.6 100 212])
Though in this case I'd probably give the anonymous function a different name and input argument name, to be slightly more descriptive.
tempF2C = @(tempF) 5*(tempF-32)/9;
tempF2C([-40 0 32 98.6 100 212])
henry tochukwu
henry tochukwu 2019 年 12 月 2 日
I greatly appreciate the answer.
It was 100% helpful.
but permit me to ask this last question
what if they are more than one variable?
e.g. c = ((x^2)*t + 5w)/2
thanks.
Steven Lord
Steven Lord 2019 年 12 月 2 日
Anonymous functions can have multiple inputs. They can also "remember" the values variables in the workspace had when they were created so you don't have to specify them as inputs. For this latter point, you cannot change the "remembered" values without recreating the anonymous function; changing the variable the anonymous function "remembered" afterwards won't change the anonymous function's "memory".
n = 2;
f = @(x, y) n*x+y;
f(3, 1) % 2*3 + 1 = 7
f(5, 9) % 2*5 + 9 = 19
n = 5;
f(3, 1) % still 2*3 + 1 = 7, not 5*3 + 1 = 16
f = @(x, y) n*x+y; % This new f now "remembers" n = 5 not n = 2
f(3, 1) % now 5*1 + 1 = 16
For more information on anonymous functions see this documentation page.
henry tochukwu
henry tochukwu 2019 年 12 月 2 日
Thanks
Matt J
Matt J 2019 年 12 月 2 日
@henry, if you consider your question answered, you should Accept-click the answer you prefer.
henry tochukwu
henry tochukwu 2019 年 12 月 7 日
din't see accept on steven lords answer, so I had to accept another answer.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by