fprintf for command window
17 ビュー (過去 30 日間)
古いコメントを表示
trying to Create output for the command window using fprintf " using matlab 2018b"
x = 2;
y = 4;
z = 7;
h = 9;
sol1 = x + h
sol2 = z/h
sol3 = y*cos(z)
sol4 = sqrt(h)*(z)^2
sol5 = abs(-x)/log(y)
fprintf('%s%4i\n',' Addition: ',A)
fprintf( )
2 件のコメント
Walter Roberson
2019 年 1 月 27 日
I don't see an assignment to a variable A and if it is intended to be a function with no inputs, it would sure help to see the code for it...
回答 (1 件)
madhan ravi
2019 年 1 月 28 日
According to your question https://www.mathworks.com/matlabcentral/answers/441913-how-to-use-fprintf-to-create-output-for-command-window A is not given anywhere so:
A=[1:5;[sol1 sol2 sol3 sol4 sol5]];
fprintf('Solution %d: %.2f\n',A)
1 件のコメント
madhan ravi
2019 年 1 月 28 日
https://www.mathworks.com/help/matlab/ref/fprintf.html#btf8xsy-5 - see those examples to practice more.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!