how to use a function
古いコメントを表示
i have a function that convert numbers to arabic letters called " num2wordsarabe" it works good,but when i try to use it directly in "strrep" or any other function ,it does not work ,also i tried to pose x=num2wordsarabe(n) and use "x" in "strrep",it didnt work neither here is the exampl:
for i=1:length(str)
if (abs(str(i))>=48)&&(abs(str(i))<=57)
n=str2double(str(i));
num2wordsarabe(n);
str=strrep(str,str(i),num2wordsarabe(n));
end
end
result on workspace:
[ ??? Error using ==> num2wordsarabe
Too many output arguments.
Error in ==> test at 15
str=strrep(str,str(i),num2wordsarabe(n));]
Any help is greatly appreciated.
4 件のコメント
Sad Grad Student
2015 年 2 月 21 日
Can you paste the code of your function here?
ben zekri raouf
2015 年 2 月 21 日
編集済み: John D'Errico
2015 年 2 月 21 日
John D'Errico
2015 年 2 月 21 日
編集済み: John D'Errico
2015 年 2 月 21 日
Please use the code formatting button when you post code. I've fixed it for you.
Andrew Newell
2015 年 2 月 21 日
I reformatted the original question. I assume that the curly brackets were an attempt to format it, not the code.
採用された回答
その他の回答 (1 件)
Sad Grad Student
2015 年 2 月 21 日
Try making the first line of your function as:
function [x] = num2wordsarabe(n)
And now use it in strrep. I'm no expert in Matlab but give that a try!
2 件のコメント
Andrew Newell
2015 年 2 月 21 日
Just
function x = num2wordsarabe(n)
will also work. And the line
num2wordsarabe(n);
isn't needed.
ben zekri raouf
2015 年 2 月 21 日
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!