Reading a Matrix with operator and Cell Array from Excel
Afficher commentaires plus anciens
Hello,
I have Two questions reading the function (xlsread).
Q1) How to read a matrix that has element(s) with an operator e.g.(+).
To illustrate what I want I wrote a simple code, where I have a Matrix named M, the first element is (n+1).
I want to know if possible how to write the Matrix M in excel sheet and then read in Matlab from the excel sheet.
This is the code
% Q1) Reading Matrix with operator from excel
n=1;
for i=1:3
M=[n+1 2;3 4] % Instate of writing Matrix M here, I want to read it from excel.
n=n+1;
end
The results of the code are:
M =
2 2
3 4
M =
3 2
3 4
M =
4 2
3 4
Q2) How to read a Cell Array from Excel
Similarly I want to know if possible how to write a cell array in excel sheet and then read it in Matlab from the excel sheet.
% Q2) Reading Cell Array from excel
C={1,[2 3];1,[4 5 6]} % How to read this cell array from excel?
C{1,2} % just to view what is inside
C{2,2} % just to view what is inside
The results should be:
C =
[1] [1x2 double]
[1] [1x3 double]
ans =
2 3
ans =
4 5 6
The reason I want to read the matrix and the cell array from excel is because I am dealing with quite big matrix and cell array, and I found editing them from excel is much easier.
Thank you in-advance
Alaa
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Spreadsheets dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!