Trouble with fprinft and transpose.
4 views (last 30 days)
Show older comments
I'm new to MATLAB and coding and I could use some help. I have four row vectors. I want to make a table with four columns. The first variable won't transpose to column with fprintf, why?
>> fprintf ('\t%.1f %7.4f %7.4f %10.4f \n', A', x', y', z')
0.0 36.0000 72.0000 108.0000
144.0 180.0000 216.0000 252.0000
288.0 324.0000 360.0000 -0.0000
-0.3 -0.5662 -0.7839 -0.9269
-1.0 -0.9269 -0.7839 -0.5662
-0.3 -0.0000 -0.0000 -0.1267
-0.4 -0.6897 -0.9009 -0.9775
-0.9 -0.6897 -0.4004 -0.1267
-0.0 -0.0000 -0.2893 -0.5552
-0.8 -0.9228 -0.9775 -0.9228
-0.8 -0.5552 -0.2893 -0.0000
Here are my variables: >> A,x,y,z
A =
0 36 72 108 144 180 216 252 288 324 360
x =
0 -0.2965 -0.5662 -0.7839 -0.9269 -0.9775 -0.9269 -0.7839 -0.5662 -0.2965 0
y =
0 -0.1267 -0.4004 -0.6897 -0.9009 -0.9775 -0.9009 -0.6897 -0.4004 -0.1267 0
z =
0 -0.2893 -0.5552 -0.7742 -0.9228 -0.9775 -0.9228 -0.7742 -0.5552 -0.2893 0
2 Comments
per isakson
on 27 Oct 2017
See my function tprintf, tprintf writes tabular data to a text file. The answer is under the tab, Examples.
Accepted Answer
More Answers (1)
Star Strider
on 27 Oct 2017
Since all your variables are row vectors, try this:
fprintf ('\t%5.1f %7.4f %7.4f %10.4f \n', [A; x; y; z])
It should give you the result you want.
3 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!