how to read and plot excel file
显示 更早的评论
Hi all,
I want to read an excel file, use the data to calculate, then plot the result in result file. I have this code so far;
namefile=input('Name the file for your result:','s');
result_file_name=sprintf('%s%s',namefile,'.xlsx');
save result_file_name;
FileNamE=sprintf('%s %s','Your result file will be name as:',result_file_name);
disp(FileNamE)
xlswrite(result_file_name,1);
excelfile=sprintf('%s%s','C:\Users\This Laptop\Desktop\MATLAB\',result_file_name);
Excel = actxserver ('Excel.Application');%excel always opened so that works faster
File=excelfile;
Excelworkbook=Excel.workbooks.Open(File);
input_data=xlsread('inputdata_size.xlsx',1,'(A2:AG553)');
[nofinput]=length(input_data(:,1)); %to calculate number of rows
start=input('press enter to start');
for ww=1:552;
ii=input_data(ww,:);
run_1=ii;
mass=run_1(:,9); %read from excel file, column#9
density=run_1(:,10); %read from excel file, column#10
step_number=552;
[uu]=step_number;
[cc]=2;
AAA=zeros(uu,cc);
clear uu cc
size=(2*((3*mass)/(4*density*pi))^(1/3));
AAA(ww,:)=[size];
end
header_result_file_name={'size'};
xlswrite1(result_file_name,header_result_file_name,ww,'A1');
xlswrite1(result_file_name,AAA,ww,'A2');
Excelworkbook.Worksheets.Item(ww).Range('A1:B1').Interior.ColorIndex = 40;
Excelworkbook.Save
Excelworkbook.Close(false)
Excel.Quit;
delete(Excel);
toc
But the problem is, the results plotted in different sheet in excel file. There are 552 sheets, 1 result per sheet. I'm expecting to have a list of 552 results in just one column (in 1 sheet). I guest something wrong with xlswrite1 command, or maybe with 'for' loop, but I'm not sure where is it. Please help. Thanks
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!