Wrong results with my GUI project

Hello, I wrote a code with GUI to solve an equation using functions. The idea is to insert an input in the first button(edit1) and upon pushing run (with push botton), the function works and reveal the output into edit2 button. My function is:
function tau = TEmodel(radius)
a = radius + 0.166;
b = radius./a;
c = 1./(2*pi);
d = 2*pi*radius;
e = d./a;
f = sin(e);
L = 2*(1-b+(c*f));
tau =1./L;
end
and below the pushbutton I wrote;
x = str2double(get(handles.edit1,'string'));
tau = TEmodel(x);
set(handles.edit2,'string',tau);
The problem is the wrong output. Because with input (in edit1)=10, the putput (in edit2) must be ~0.6 while I got 17462.9? Could anyone help me?

回答 (2 件)

Thorsten
Thorsten 2016 年 8 月 29 日
編集済み: Thorsten 2016 年 8 月 29 日

0 投票

There is an error in your formula / function. I also get TEmodel(10) = 17462.89, w/o any GUI.
What should TEmodel compute based on the radius?
Maybe there is an error due to angles given in radians vs. degree?

2 件のコメント

ahmed Gamal
ahmed Gamal 2016 年 8 月 29 日
編集済み: ahmed Gamal 2016 年 8 月 29 日
it computes the time of a particle confined in a pore of radius r and it is independent of anything else and there are no units mistakes. I used the same function but to draw the results and I got right results. Is there any problem if I used the same function for two m files?
Thorsten
Thorsten 2016 年 8 月 31 日
No, you can use the function in as many m-files as you like. But the function returns 17462.89 for input of 10. So if this is wrong, you have to rewrite your function.

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

Rachit Kumar
Rachit Kumar 2016 年 8 月 29 日
編集済み: Rachit Kumar 2016 年 8 月 29 日

0 投票

The output of function TEmodel for radius = 10 is 1.7463e+04. Hence, the issue is with the function TEmodel not with the GUI.

カテゴリ

ヘルプ センター および File ExchangeProgramming についてさらに検索

タグ

質問済み:

2016 年 8 月 29 日

コメント済み:

2016 年 8 月 31 日

Community Treasure Hunt

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

Start Hunting!

Translated by