Question about functions in MATLAB
古いコメントを表示
What is the difference between this code
function result = square(n)
result = n*n;
end
and this code
number = 4;
numberSquared= square(number);
disp(numberSquared);
Like I'm confused about the first code specifically. Are both the codes doing the same thing or is there a difference?
採用された回答
その他の回答 (1 件)
shaik faraz
2022 年 4 月 8 日
0 投票
upper one is a function
lower one is a script
script only gets you result if u run that particular script
but function can be called from other scripts
カテゴリ
ヘルプ センター および File Exchange で Language Support についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!