How to display a result
조회 수: 30 (최근 30일)
이전 댓글 표시
Hi,
How to print a statement which has two variables.,for eg., h is the input for the function and f is the output value.
h=[50 100]
f = 149
f = 151
I can write, fprintf( 'The value of f is = %.2f\n ',f ) which displays two statements.
But I want to print a statement 'The value of f at h is = ?'. (The value at h1 is : 149, the value of h2 is 151)
댓글 수: 5
Dyuman Joshi
2022년 7월 14일
h=[10 20 30];
f=h.^3+2*h-h.^2;
fprintf('The frequency at %d m is: %f\n',[h;f])
채택된 답변
Abhijit Nayak
2022년 7월 14일
h=[10 20 30];
[m,n]=size(h);
for i=1:n
f=h(i).^3+2*h(i)-h(i).^2;
fprintf("The value at "+h(i)+"m is %f\n",f);
end
% The above code will run fine
댓글 수: 2
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!