Trouble Formatting fprintf Table
이전 댓글 표시
I'm trying to make a simple table with 4 rows, 2 columns, and 2 headers. I can't quite seem to figure out how to edit it so that it's correct. Here's what I have so far:
T= [-10 0.0 10 20];
V= [0.0 5.0 10.0 15.0];
fprintf('Temperature (C): \t Voltage (volts):\n)%2.0f %2.0fT',[T,V].')
And here is the output:
Temperature (C): Voltage (volts):
)-10 0TTemperature (C): Voltage (volts):
)10 20TTemperature (C): Voltage (volts):
) 0 5TTemperature (C): Voltage (volts):
)10 15T>>
답변 (1개)
dpb
2013년 9월 5일
Put the position of the numeric fields in wrong place...
>> fprintf('Temperature (C): %3.0f Voltage (volts): %2.0f \n',[T,V]')
Temperature (C): -10 Voltage (volts): 0
Temperature (C): 10 Voltage (volts): 20
Temperature (C): 0 Voltage (volts): 5
Temperature (C): 10 Voltage (volts): 15
>>
카테고리
도움말 센터 및 File Exchange에서 Whos에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!