필터 지우기
필터 지우기

trouble printing string and matrix using fprintf

조회 수: 2 (최근 30일)
Robert Munoz
Robert Munoz 2020년 12월 11일
답변: Walter Roberson 2020년 12월 11일
so I have a 20x1 string which is
B=[Alanine Arginine Asparagine Aspartic Cysteine Glutamic Glutamine Glycine Histidine Isoleucine Leucine Lysine Methionine Phenylanlanine Proline Serine Threonine Tryptophan Tyrosine Valine]
which was original a cell that was taken from an excel file and I have a 1x20 matrix which is
Z=[ 89.0941 175.2109 132.1192 132.0960 121.1601 146.1229 146.1461 75.0672 156.1644 131.1748 131.1748 147.1974 149.2139 165.1919 116.1399 105.0935 119.1204 203.2206 469.7853 117.1479]
. Im supposed to display both of them side by side to one another vertically so one column is the B and the second column Z. When is use frpintf I cant get it to display properly. I use
fprintf('%s %f\n', B, Z);
to display them but everytime I use it I get
Alanine NaN
Asparagine NaN
Cysteine NaN
Glutamine NaN
Histidine NaN
Leucine NaN
Methionine NaN
Proline NaN
Threonine NaN
Tyrosine NaN
8.909412e+01 175.210860
1.321192e+02 132.095980
1.211601e+02 146.122860
1.461461e+02 75.067240
1.561644e+02 131.174760
1.311748e+02 147.197380
1.492139e+02 165.191880
1.161399e+02 105.093520
1.191204e+02 203.220620
4.697853e+02 117.147880
When I run the string and the matrix seperately using fprintf they display properly. How can I display them side by side properly?

답변 (1개)

Walter Roberson
Walter Roberson 2020년 12월 11일

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by