How to store data from matlab in excel file after each iteration

1 回表示 (過去 30 日間)
Vishal Sharma
Vishal Sharma 2017 年 1 月 27 日
コメント済み: Vishal Sharma 2017 年 1 月 27 日
How to store data from matlab in excel file after each iteration rows=1:4; col=1:2; v =
1 2
1 3
1 4
2 1
2 3
2 4
3 1
3 2
3 4
4 1
4 2
4 3
Matrix A is
A=[0 1 0 1;1 0 0 0;1 0 1 0;0 0 0 1]
I want to multiply two elements of A vector each time row wise as per permutation combination of V Vector e.g. A(1st row all elements) to be multiplied by A(2nd row all elements) the code for which is
for b=1:size(v,1)
for c=1:size(v,2)-1
for i=1: size(A,1)
B=A(i,(v(b,c)))* A(i,(v(b,c+1)));
C=[B, A(i,(v(b,c))), A(i,(v(b,c+1)))];
end
end
end
I want to store values of ‘C’ every time generated in this loop in an excel file.....
Thanks

採用された回答

KSSV
KSSV 2017 年 1 月 27 日
You first get your final matrix, say R...and use
xlswrite(filename,R)
  8 件のコメント
KSSV
KSSV 2017 年 1 月 27 日
clc; clear all ;
A=[0 1 0 1;1 0 0 0;1 0 1 0;0 0 0 1] ;
v=[1 2;1 3;1 4;2 1;2 3;2 4;3 1;3 2;3 4;4 1;4 2;4 3] ;
count = 0 ;
iwant = zeros(size(v,1)*size(v,2)-1,3) ;
for b=1:size(v,1)
for c=1:size(v,2)-1
for i=1: size(A,1)
B=A(i,(v(b,c)))* A(i,(v(b,c+1)));
C=[B, A(i,(v(b,c))), A(i,(v(b,c+1)))] ;
end
count = count+1 ;
iwant(count,:) = C ;
end
end
xlswrite('hello.xlsx',iwant)
Vishal Sharma
Vishal Sharma 2017 年 1 月 27 日
Thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by