MATLAB Answers

Exporting data from matlab to a excel with a special pathway

조회 수: 2(최근 30일)
Rengin
Rengin 9 Sep 2019
답변: Rengin 9 Sep 2019
Dear Users! Imagine that I have the matrices of Y1=rand(5), Y2=rand(7) and Y3=rand(4). I want to specifically export these matrices to an excel file at Desktop with a file name of Admittance.xlsx. Y1, Y2 and Y3 should be on Sheet 1, Sheet 2 and Sheet 3, respectively. Could you please help me to do it? Thanks a lot!

  댓글 수: 0

로그인 to comment.

답변(2개)

Alex Mcaulley
Alex Mcaulley 9 Sep 2019
xlswrite(filename,Y1,1)
xlswrite(filename,Y2,2)
xlswrite(filename,Y3,3)

  댓글 수: 4

표시 이전 댓글 수: 1
Alex Mcaulley
Alex Mcaulley 9 Sep 2019
filename = fullfile('yourPath','Admittance.xlsx') %where yourPath is the folder where you want to save the file
Rengin
Rengin 9 Sep 2019
filename = fullfile('\\etieeh.loc\homes\evma\cabadag\Desktop\Econs','Admittance.xlsx')
% I do exactly what you suggest. It doesn't work somehow. Do I make a mistake somewhere?
Alex Mcaulley
Alex Mcaulley 9 Sep 2019
What do you mean with "It doesn't work"? Do you get any error? If this is the case, please copy-paste the full error text

로그인 to comment.


Rengin
Rengin 9 Sep 2019
% When I run the code below, it creates Admittance.xlsx at the location I want, no problem.
% The problem is that I have to add extra sheets in Admittance.xlsx (as many as the number of Y matrices).
% I doesn't add e.g. 3 sheets (for Y1, Y2 and Y3) in Admittance.xlsx automatically.
% The error message:
% Error using xlswrite (line 226)
% Error: The object invoked has disconnected from its clients.
%
%
%
% Error in DataExpImp (line 18)
% xlswrite(baseFileName,Y2,2)
clear
clc
close all
% Create the matrices
Y1=rand(5);
Y2=rand(7);
Y3=rand(4);
folder = '\\etieeh.loc\homes\EVMA\cabadag\Desktop\Econs';
% if ~exist(folder, 'dir')
% mkdir(folder);
% end
baseFileName = 'Admittance.xlsx';
fullFileName = fullfile(folder,baseFileName);
xlswrite(baseFileName,Y1,1)
xlswrite(baseFileName,Y2,2)
xlswrite(baseFileName,Y3,3)

  댓글 수: 0

로그인 to comment.

이 질문에 답변하려면 로그인을(를) 수행하십시오.


Translated by