I'm so frustrated with MATLAB when I came across the same problems as you firstly,even though there were much changes.But just now I appreciate MATLAB highly because the problem have been dealed with long before.Please reference the cite http://www.mathworks.com/help/matlab/data-import-and-export.html#f5-15527 Exporting a Cell Array to a Text File. Then u can copy the strings from .dat/txt file to *.xls file
Write text arrays to excel
6 次查看(过去 30 天)
显示 更早的评论
Hi,
I want matlab to write all the text in an array to a certain cell in an excel file. First I define the array "Nida":
Nida = char('3-20', '3-28', '3-45', '4-20', '6-20')
Then I define a loop that goes through all the values of "Nida"; within this loop there is another loop which will add letter by letter the text from "Nida" to "Nida_val". After this loop "Nida_val" thus equals 3-20, 3-28, 3-45, 4-20 or 6-20 dependent on the value of a. (It loops until length(Nida)-1 because using length(Nida)gives a value which is 1 to high, not sure why though.)
for a = 1:5
for ct = 1:length(Nida)-1
Nida_val(1,ct) = Nida(a,ct)
end
Now I want "Nida_val" to be written in an excel file. Note that the text need to be written to a worksheet which isn't the first worksheet.
xlswrite('Compression panneaux 09-2011 indA.xls', Nida_val, 'ModèleAvecCorrectionPlasticité', 'B4');
end
Using this command will however write each letter of Nida_val to a separate cell instead while I want all the text in Nida_val to be in one cell. Using the command dlmwrite will allow me to define a delimiter so that I can use nothing and everything would be in one cell but now it isn't possible to write to another worksheet other then the first one.
What is the most efficient way to write a string to one cell in excel on a certain worksheet?
The full code:
Nida = char('3-20', '3-28', '3-45', '4-20', '6-20')
for a = 1:5
for ct = 1:length(Nida)-1
Nida_val(1,ct) = Nida(a,ct)
end
xlswrite('Compression panneaux 09-2011 indA.xls', Nida_val, 'ModèleAvecCorrectionPlasticité', 'B4');
end
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!