I can't output my data into excel in rows even though it is a 17x1 array

조회 수: 1 (최근 30일)
Alexander Purvis
Alexander Purvis 2021년 11월 16일
댓글: Alexander Purvis 2021년 11월 17일
I have 6 data sets that are each 17x1 arrays. I want to output them to an .xlsx file and add names to the top of the columns. I have used the following code:
writetableA={'Hp','V0','fuel','RoC',textdelta,'\nu ';'(ft)','(kts)','(kg)','(fpm)','\circ','(kts)';HpA,TASA,FuelA,RoCoutputA,dA,vwA}
filename='Part1_GpA.xlsx';
writecell(writetableA,filename,'Sheet','Group_A','Range','A2')
When I open the .xlsx file everything is in columns. I tried to put HpA.',TASA.',FuelA,' etc. to transpose them but it didn't change anything.
On a side note how do I get the symbols to show as symbols?

답변 (1개)

KSSV
KSSV 2021년 11월 16일
USe write2table. Read about it.
  댓글 수: 3
KSSV
KSSV 2021년 11월 17일
x = rand(10,1) ;
y = rand(10,1) ;
z = rand(10,1) ;
T = table(x,y,z)
T = 10×3 table
x y z _______ _______ ________ 0.72052 0.55336 0.060796 0.41676 0.90342 0.76859 0.36714 0.52817 0.47548 0.97019 0.97504 0.16776 0.40196 0.59177 0.23772 0.45347 0.82538 0.38454 0.85016 0.50397 0.32527 0.77764 0.47916 0.98926 0.14376 0.81475 0.91183 0.75603 0.27602 0.49391
After making table like shown above use write2table.
Alexander Purvis
Alexander Purvis 2021년 11월 17일
Hi,
Thank you for your answer. I get why you sent that but it didn't help me entirely. I wanted to have the data in that format and be able to have a title+subtitle for each variable.
I used this code in the end:
filename='Part1_GpA.xlsx'; % Create .xlsx file
varNames={'Hp','V0','fuel','RoC','\delta','\nu '}; % Title of variables
tableA=table(HpA,TASA,FuelA,RoCoutputA,dA,vwA,'VariableNames',varNames); % Create table of values
tableAnew=tableA([1:1,1:end], :); % Add blank row as space for units
writetable(tableAnew,filename,'Sheet','Group_A','Range','A1') % Write newtable into .xlsx
varunits={'(ft)','(kts)','(kg)','(fpm)','\circ','(kts)'}; % Create array of unit names
writecell(varunits,filename,'Sheet','Group_A','Range','A2') % Write unit names into
Which outputted the data into excel, added a blank row and inserted a second set of data into it for the units. It's not elegent but it works.
Can you please tell me how I can get \nu and the other symbols to be outputted as such?

댓글을 달려면 로그인하십시오.

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by