how to size and paste plots to Excel
3 次查看(过去 30 天)
显示 更早的评论
I am reading a csv file into matlab from an IMU and want to plot the analyzed data (accelerations and velocities) into an excel file. I am able to designate the start point of each plot using the "range = (whichever cell I choose)" command, but am unable to resize the plots to get them to fit on one sheet. I am using matlab 2014b and office 2013.
Any help will be much appreciated.
My attempt at coding (a bit busy as I've been trying different things):
plot(time_axis,IMU_Accel);
grid on;
ylim([-5,5]);
xlabel('Time(sec)');
ylabel('Acc_x_b (m/sec^2)');
print -dmeta; %.................Copying to clipboard
FILE = filename1;
SheetIndex=1;
Range ='K1';
%.............excel COM object............
Excel = actxserver ('Excel.Application');
Excel.Visible = 1;
if ~exist(FILE,'file')
ExcelWorkbook=Excel.Workbooks.Add;
ExcelWorkbook.SaveAs(FILE);
ExcelWorkbook.Close(false);
end
invoke(Excel.Workbooks,'Open',FILE); %Open the file
Sheets = Excel.ActiveWorkBook.Sheets;
if gt(SheetIndex,3)
for i=1:SheetIndex-3
Excel.ActiveWorkBook.Sheets.Add;
end
end
ActiveSheet = get(Sheets, 'Item', SheetIndex);
% set(ActiveSheet,'Name',SheetName)
ActiveSheet.Select;
ActivesheetRange = get(ActiveSheet,'Range',Range);
ActivesheetRange.Select;
ActivesheetRange.PasteSpecial; %.................Pasting the figure to the selected location
Excel.ActiveWorkbook.Save% Now save the workbook
if eq(Excel.ActiveWorkbook.Saved,1)
Excel.ActiveWorkbook.Close;
else
Excel.ActiveWorkbook.Save;
end
invoke(Excel, 'Quit'); % Quit Excel
close Figure 1
0 个评论
回答(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!