Hi everyone, I'm a very young user of Matlab and completely new to the programming world. I'm trying to do a simple matlab program that ables me to calculate a simple Mathematical equation ( Newton's Law F=m.a).
I've done this simple code:
function F = Newton(m, a)
F=m*a
end
So, if I in Matlab type:
x=Newton(2,2) I get the result correctly.
So I tried to compile this simple .m file with the help of deploytool. But when I finish to create the .exe file, when I click on it nothing happens.
And, if I go to that .exe file through DOS line command, I can see that the error I get is:
Error using newton (line2) Not enough input arguments. MATLAB:minrhs
So, I need your help. I'm very new to this so I'm sorry if it is a stupid question.
Thanks to all that will try to help me
Regards

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 28일

1 개 추천

when you compile only the function, how are you going to call this function? I think you should create a script with, for example inputdlg to introduce your data and msgbox or gui to display your result

댓글 수: 7

ropbasuel
ropbasuel 2013년 3월 28일
I see.. So the problem is that I need some kind of dialog for the program know things right?
Is there any example I can see how this system works?
Thank you for your answer
Example
a=inputdlg('enter a');
a=str2double(a);
y=sin(a)
msgbox(['the result is' num2str(a)])
ropbasuel
ropbasuel 2013년 3월 28일
편집: ropbasuel 2013년 3월 28일
Thank you for your example! Can you tell me what is wrong in this?
inputdlg ('enter a')
a=str2double(a);
inputdlg('enter m')
m=str2double(m);
F = m*a;
msgbox(['The result is' num2str(F)])
I get this error:
Undefined function or variable 'a'.
Error in newton (line 2) a=str2double(a);
Thanks
it's
a=inputdlg ('enter a')
ropbasuel
ropbasuel 2013년 3월 28일
Oh.. Now it works! Thank you for the help. Can I make only one more question?
Instead of having 2 steps in asking the variables, can I ask both variables at the same time? Like making a dialog with two different blank cases for me to put the values of "m" and "a" at the same time!
Thanks
x=inputdlg({'enter a','enter b'})
a=x{1}
b=x{2}
ropbasuel
ropbasuel 2013년 3월 28일
Thank you Azzi! I really appreciate your help!
Thanks for your time!

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

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Scripts에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by