Trouble Formatting fprintf Table
Ältere Kommentare anzeigen
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>>
Antworten (1)
dpb
am 5 Sep. 2013
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
>>
Kategorien
Mehr zu Whos finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!