why i getting Output argument error ?

I wrote this function code but I want to know why I getting this error
Error in ==> WvPr at 19 g = 9.8; % gravity acceleration in m/s^2
??? Output argument "HmoJfl" (and maybe others) not assigned during call to "C:\Users\Mac\Documents\MATLAB\WvPr.m>WvPr".
Error in ==> Untitled at 7 [HmoJfl,TpJfl,HmoJfd,TpJfd,HmoPMfd,TpPMfd]=WvPr(U10,X);
and if You can help me to correct it I'm really thank you :(
THANK YOU IN ADVECE

回答 (2 件)

Matt J
Matt J 2014 年 12 月 30 日

0 投票

The first line of the function WvPr() has a list of output arguments
HmoJfl,TpJfl,HmoJfd,TpJfd,HmoPMfd,TpPMfd
that it promises to return. However, this promise is not being fulfilled. The error message means that these variables are not computed anywhere in the mfunction.

4 件のコメント

per isakson
per isakson 2014 年 12 月 30 日
編集済み: per isakson 2014 年 12 月 30 日
... and that's because
K>> m = 1:Cd;
K>> m
m =
Empty matrix: 1-by-0
What value do you intend to assign to m?
&nbsp
Here are some links on debugging in Matlab
lina
lina 2014 年 12 月 30 日
the attached m file shows where I use these variables in addition, there is other m file to put the values of X and U10-which I get the error.
per isakson
per isakson 2014 年 12 月 30 日
Start to use the debugging features to find out what is going on in your code.
lina
lina 2014 年 12 月 30 日
ok, thank you

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

Star Strider
Star Strider 2014 年 12 月 30 日

0 投票

Check the value of ‘U10’. By my calculations, if it is <28540, ‘Cd’<1, ‘m’ will be empty, and none of the loops will ever execute.

6 件のコメント

lina
lina 2014 年 12 月 30 日
if that possible, more explanation please.
Star Strider
Star Strider 2014 年 12 月 30 日
編集済み: Star Strider 2014 年 12 月 30 日
If you set ‘Cd’=1 here:
Cd = (0.001)*(1.1+0.035*(U10))
and solve for ‘U10’, the result is 28540. If ‘U10’ is less than that value, ‘m’ will be empty. The main loop will then not execute, and none of the return values will be calculated.
To see the effect on ‘m’ if ‘U10’ is less than 28540, run these lines:
U10 = 28539;
Cd = (0.001)*(1.1+0.035*(U10))
m = 1:Cd
The function should be edited with the additional error-catching block at the beginning of the code:
if U10 < 28540
error('WvPr error: U10 must be at least 28540')
return
end
lina
lina 2014 年 12 月 30 日
編集済み: lina 2014 年 12 月 30 日
even if the U10 value is input? I mean the user enter the U10 value!
Star Strider
Star Strider 2014 年 12 月 30 日
If the ‘U10’ value is less than 28540, none of the loops execute. The error block would catch that, issue the error, and return to the calling program, rather than giving you the ‘unassigned output argument’ error.
Check the value of ‘U10’ in your program. If it is less than 28540, you will have to debug your code to find the reason, then correct your code so that the value of ‘U10’ is large enough. Otherwise, you will not be able to use the ‘WvPr’ function.
lina
lina 2014 年 12 月 30 日
ok I will check right now thank you very much for these explanations
Star Strider
Star Strider 2014 年 12 月 30 日
My pleasure!

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

カテゴリ

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

質問済み:

2014 年 12 月 30 日

コメント済み:

2014 年 12 月 30 日

Community Treasure Hunt

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

Start Hunting!

Translated by