HOW CAN I CREATE A MATRIX FILE FROM 3 EXCEL FILES
1 回表示 (過去 30 日間)
古いコメントを表示
For example I have three excel files
File1
1 2 3
4 5 6
7 8 9
File2
10 11 12
13 14 15
16 17 18
File3
19 20 21
22 23 24
25 26 27
I want to create matrices in form of
1 10 0
-10 19 0
0 0 0
2 11 0
-11 20 0
0 0 0
3 12 0
-12 21 0
0 0 0 .......and so on. help me with this. Consider this matrix as a tensor for every point in a body. I have to multiply these matrices with another matrices. So what should be the format or type of final file?
0 件のコメント
回答 (1 件)
Erivelton Gualter
2019 年 5 月 3 日
First, there is several ways to import data into Matlab. CHeck the following link:
I recomend to take a look in this answer in order to read the matrix into variables File_i.
https://www.mathworks.com/matlabcentral/answers/161579-how-can-i-import-a-specific-matrix-from-an-excel-file-using-the-xlsread-command
Then, to create the matrix in your desired way, you can check the following code:
clear all
% Matrix
File1 = [1 2 3; 4 5 6; 7 8 9];
File2 = [10 11 12; 13 14 15; 16 17 18];
File3 = [19 20 21; 22 23 24; 25 26 27];
% Size Matrix
[n,m] = size(File1);
N = n*m;
% Reshape
file1 = reshape(File1.', 1, N);
file2 = reshape(File2.', 1, N);
file3 = reshape(File3.', 1, N);
for i=1:N
a = file1(i);
b = file2(i);
c = file3(i);
Out = getM(a,b,c) % Show Output
end
% Function to get Matrix in the desired format.
function out = getM(a,b,c)
out = [a b 0; -b c 0; 0 0 0];
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Import from MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!