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!