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!