필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to upload words into a spreadsheet and then to a structure?

조회 수: 1 (최근 30일)
Shane
Shane 2014년 7월 2일
마감: MATLAB Answer Bot 2021년 8월 20일
I'm making a plot of certain events. Each event has plot coordinates already in the structure. However, I want to label each event. I'm trying to transfer the names through a spreadsheet, but I keep getting the not a number (NaN) thing pop up. How do I save these names as an X-by-1 matrix within the structure? Thanks

답변 (1개)

Image Analyst
Image Analyst 2014년 7월 4일
I don't know what you mean by a "structure" within Excel. But to output a string to Excel it has to be inside a MATLAB cell, not just a bare string or else each character of the string will go into a new cell in Excel.
e.g. (untested)
myArray = rand(20,2);
cellArray = {'column 1', 'Column 2'} % First row is column headers.
% The following rows are the numbers.
for row = 1 : size(myArray, 1)
cellArray{row+1, 1} = myArray(row,1);
cellArray{row+1, 2} = myArray(row,2);
end
xlswrite(filename, cellArray , 'A1');
For more on cell arrays, see the FAQ: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by