Need help one multiple data exporting to xls
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi All,
I encountered some trouble in exporting and naming my data to .xls.
I'm trying to do two for loops in order to process my 30 data. I firstly remove NaN values and the use log10 to revalue them. However, for writetable code, there always shows errors.
I would very appreciate it if anyone can help me solve the bugs in my codes!
Thanks!
for time=1:6
for drug=1:5
x1 = reshape(p(drug,time,1:2,:),[],1);
y1 = reshape(N(drug,time,1:2,:),[],1);
z1 = reshape(A(drug,time,1:2,:),[],1);
X = [x1 y1 z1];
X(any(isnan(X),2),:) = [];
data_log=[log10(X(:,1)) log10(X(:,2)) log10(X(:,3))];
data_log_table=array2table(single_cell_log);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%problems for the following row
filename=['time_';num2str(time);'_drug_';num2str(drug_);'.xlsx'];
writetable(single_cell_log_table, filename)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end
end
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
Error in subsettry (line 11)
filename=['time_';num2str(time;'_drug_';num2str(drug_);'.xlsx'];
댓글 수: 0
채택된 답변
convert_to_metric
2019년 5월 15일
편집: convert_to_metric
2019년 5월 15일
Hi Haolong,
I see 2 issues on line 11. You should use commas instead of a semicolons so that you will horizontally concatenate the strings. Also, there might be a typo. Perhaps you meant num2str(drug) and not num2str(drug_). In other words, try changing:
filename=['time_';num2str(time);'_drug_';num2str(drug_);'.xlsx'];
to
filename=['time_',num2str(time),'_drug_',num2str(drug),'.xlsx'];
댓글 수: 2
Guillaume
2019년 5월 15일
I'd recommend using sprintf to create your strings. In my opinion it's a lot clearer, and it avoids having to perform any kind of concatenation:
filename = sprintf('time_%d_drug_%d.xlsx', time, drug);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!