Info

此问题已关闭。 请重新打开它进行编辑或回答。

Write mutiple matfiles in to one csv

1 次查看(过去 30 天)
Kanakaiah Jakkula
Kanakaiah Jakkula 2015-11-21
关闭: MATLAB Answer Bot 2021-8-20
I have the following code:
clc;
clear all;
close all;
tic
[~,Names_array]=xlsread('HTDNames2.csv');
[Scores,M]=xlsread('All_Data_ABCDEF3_mod2.csv');
successRateScoreTable=xlsread('successRateScoreTable.csv');
TBsuccessScoreTable=xlsread('TBsuccessScoreTable.csv');
Name_recipeTemp=M(:,1);
Name_recipe=unique(Name_recipeTemp,'rows');
a=size(Names_array,1);
recipeList(:,1)=Name_recipe;
[~,loc] = ismember([M(1:end-1,1) M(2:end,1)],Names_array');
[successCount,failureCount,successSum,failureSum] = deal(zeros(a));
for ni = 1:size(loc,1);
linearIndex = sub2ind([a,a],loc(ni,1),loc(ni,2));
switch M{ni+1,2}
case 'Success'
successCount(linearIndex) = successCount(linearIndex) + 1;
successSum(linearIndex) = successSum(linearIndex) + Scores(ni+1);
case {'Failure','Abort','Manual'}
failureCount(linearIndex) = failureCount(linearIndex) + 1;
failureSum(linearIndex) = failureSum(linearIndex) + Scores(ni+1);
end
end
successCount;
failureCount;
totalCount=successCount+failureCount;
TBsuccessMean = successSum./successCount;
TBfailureMean = failureSum./failureCount;
successRate=(successCount./totalCount)*100;
failureRate=(failureCount./totalCount)*100;
for i=1:size(totalCount,1)
for j=1:size(totalCount,2)
if(totalCount(i,j)==0)
successCount2(i,j)=NaN;
failureCount2(i,j)=NaN;
totalCount2(i,j)=NaN;
TBsuccessMean2(i,j)=NaN;
TBfailureMean2(i,j)=NaN;
successRate2(i,j)=NaN;
failureRate2(i,j)=NaN;
else
successCount2(i,j)=successCount(i,j);
failureCount2(i,j)=failureCount(i,j);
totalCount2(i,j)=totalCount(i,j);
TBsuccessMean2(i,j)=TBsuccessMean(i,j);
TBfailureMean2(i,j)=TBfailureMean(i,j);
successRate2(i,j)= successRate(i,j);
failureRate2(i,j)=failureRate(i,j);
end
end
end
toc
I want to write the the following output data into different sheets (sheet1,sheet2...etc) of same excel file (or CSV):
Output1:recipeList (in sheet1)
Output2: successCount (in sheet2)
Output3:successCount2 (in sheet3)
Output4:successRateScoreTable (in sheet4)
I use xlswrite for one sheet, but I am unable use xlswrite for multiple sheets. Kinldy some one help.
Many thanks in advance.

回答(1 个)

Geoff Hayes
Geoff Hayes 2015-11-21
Kanakaiah - according to the documentation for xlswrite all you should need to do is the following
filename = 'myXlsFile.xlsx';
xlswrite(filename, recipeList, 1);
xlswrite(filename, successCount, 2);
xlswrite(filename, successCount2, 3);
xlswrite(filename, successRateScoreTable, 4);
You mention how you can write to one sheet but not multiple? Did you try doing something similar to the above or something else altogether? If you are observing any errors, then please post them.

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by