wirte in excel sheet.

10 ビュー (過去 30 日間)
Silpa K
Silpa K 2019 年 10 月 10 日
回答済み: Shubham Gupta 2019 年 10 月 10 日
I need to write some arrays in specified rows.I use xlswrite('Book1.xlsx',q,'A11:BI2').But I get the same answer in each rows.The second row is also same as the first.But I need each rows are different.How can I get different values.
  5 件のコメント
Shubham Gupta
Shubham Gupta 2019 年 10 月 10 日
Do this, after running your current code type:
whos q
in command window and let us know what is the output.
Silpa K
Silpa K 2019 年 10 月 10 日
Iam getting different q in each process and the q value is an array
ts = xlsread('ECGFiveDays_TEST.xlsx');
p=ts(11:11,2:end);
fa = movstd(p,20,1);
secarray = movstd(fa,20,1) ;
k=maxk(secarray,10);
[~,ii] = min(abs(p(:) - k(:)'));
out = p(unique(ii));
subSequence{1} = p(1:30);
subSequence{2} = p(31:60);
subSequence{3} = p(61:90);
subSequence{4} = p(91:120);
subSequence{5} = p(121:end);
A = [];
for ii = 1:length(subSequence)
if any(ismember(subSequence{ii},out))
A{end+1} = subSequence{ii};
aa = ii;
disp(aa);
end
end
idx=1:length(aa);
bb= subSequence{3};
cc=subSequence{2};
q=[idx bb cc];
xlswrite('Book1.xlsx',q,'A11:BI2')
Here Iam changing the p value for each process,taking different rows with respect to that the xlswrite also.
Dataset attached here.

サインインしてコメントする。

回答 (2 件)

prasanth s
prasanth s 2019 年 10 月 10 日
Delete the already created excel sheet.
Change the last line of code to
xlswrite('Book1.xlsx',q,'A1:BI1')
if you want to store in the second row, then change the 'A1:BI1' to 'A2:BI2' .

Shubham Gupta
Shubham Gupta 2019 年 10 月 10 日
So, in order to change row as you change the q, you have to change the range dynamically.
row_num = 1; % you can change that using a for loop
Range = ['A',num2str(row_num)];
xlswrite('Book1.xlsx',q,Range)
But it will only affect the performance of your code. So, what I suggest is that you store all the q array in a "master" array dynamically
i = 1; % you can change that using a for loop
master_data(i,:) = q;
and save that master array in the Excel file at the end of the code using :
xlswrite('Book1.xlsx',master_data,'A1')

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by