How to export an array text which created by a string and numbers to excel?
1 回表示 (過去 30 日間)
古いコメントを表示
Hi,
I have a numeric array a=0:100:1000
I want to precede each element of the array with 'WL' and I will get a new array: 'WL0', 'WL100', 'WL200',..., 'WL1000'.
Then I will export it excel by xlswrite. Could someone please help me to do it? I wrote by myself but I couldn't get the result I desired.
Here is my code:
clc
clear all
format short
a=0:100:1000;
wl={};
for i=1:length(a)
text=sprintf('WL%d',a(i));
wl={wl;text};
end
xlswrite(filename,wl,1,'A6');
Thanks.
0 件のコメント
採用された回答
Geoff Hayes
2014 年 10 月 4 日
Khanh - you almost have it. w1 has been (correctly) defined as a cell array, it is just the vertical concatenation that is failing at the line
wl={wl;text};
which seems to result in a 2x1 object where the first is a cell array, and the last is the last value added (text). Just change this line to the following which will create the column that you desire
wl=[wl;text];
and assign a filename
filename = 'myExcel.xls'
and you should be good to try again.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Spreadsheets についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!