Executing a fprintf statement with a function

3 ビュー (過去 30 日間)
Teoman Selcuk
Teoman Selcuk 2021 年 12 月 3 日
回答済み: Image Analyst 2021 年 12 月 3 日
How would I be able to pass and fprintf a tsring in the code below? The code below is faulty and not working
a= pass('hello');
function output = pass(var)
fprintf('%s', var);
end

回答 (1 件)

Image Analyst
Image Analyst 2021 年 12 月 3 日
Get rid of a=, or else assign a inside of the function. Right now you are trying to accept something into a in your calling routine, but the function does not pass anything back. So call it like this:
pass('hello');

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by