if command with @(x,t) equation

I want to always display error but not when error only equal zero; so far, this is what I got, but it only works when error only equal zero. thks for your help

7 件のコメント

madhan ravi
madhan ravi 2018 年 12 月 6 日
編集済み: madhan ravi 2018 年 12 月 6 日
upload the full code
Adam
Adam 2018 年 12 月 6 日
編集済み: Adam 2018 年 12 月 6 日
Well, clearly your elseif statement has a couple of problems:
Firstly the first part of it is identical to the if statement so would never get hit anyway because your code would always land in the if statement.
Then, in the same vein, the thing you and it with is its exact inverse so that statement would always evaluate to false, just like if you had the statement:
if true & false
madhan ravi
madhan ravi 2018 年 12 月 6 日
編集済み: madhan ravi 2018 年 12 月 6 日
in addition to that you can't compare a function handle ! unless it's evaluated
May97
May97 2018 年 12 月 6 日
so it is impossible to have an ''only if'' command in matlab??
Stephen23
Stephen23 2018 年 12 月 6 日
編集済み: Stephen23 2018 年 12 月 6 日
It is also highly unlikely that the floating point operations exp and cos will every evaluate to give exactly zero for that formula. This is unlikely to be a useful approach to take with floating point calculations.
Adam
Adam 2018 年 12 月 6 日
編集済み: Adam 2018 年 12 月 6 日
'Only if' is just an if statement, e.g.
if x == 0
disp( 'x is 0'
end
May97
May97 2018 年 12 月 6 日
it does not, but since for 3b uexact is not given, i cannot calcute the error. I want to use the same function for both 3a and 3b

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

回答 (1 件)

Torsten
Torsten 2018 年 12 月 6 日

1 投票

https://stackoverflow.com/questions/18183648/matlab-check-if-function-handle-is-a-particular-function-or-function-type

1 件のコメント

madhan ravi
madhan ravi 2018 年 12 月 6 日
+1 Torsten you are absolut!

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

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2018 年 12 月 6 日

コメント済み:

2018 年 12 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by