Distinguishing matrices in for loops

1 回表示 (過去 30 日間)
Oddur Bjarnason
Oddur Bjarnason 2017 年 7 月 11 日
編集済み: Oddur Bjarnason 2017 年 7 月 12 日
I want to distinguish matrices in a for loop.
The following does not work:
T=[0,1,-0.1,0.8,0;0,0,0,1,0;-0.2,-1,0,-0.2,0;0,0,0,0,0;0.2,0.5,-0.5,-0.2,0]
S0=[1,1,1,1,1]
n=0
for n=1:5
S{n}=S0*T
S{n}=(1./(1 + exp(1).^(-1*S{n})))
S{n+1}=S{n}*T
end
Can somebody help me?
  3 件のコメント
KSSV
KSSV 2017 年 7 月 12 日
You can proceed like this:
T=[0,1,-0.1,0.8,0;0,0,0,1,0;-0.2,-1,0,-0.2,0;0,0,0,0,0;0.2,0.5,-0.5,-0.2,0] ;
S0=[1,1,1,1,1] ;
S = zeros(5,length(T)) ;
for n=1:5
S(n,:)=(1./(1 + exp(1).^(-1*S0*T)))*T ;
end
What you think is not working?
David Goodmanson
David Goodmanson 2017 年 7 月 12 日
Again, this gives identical values for all rows of S, and I think an iterative process may be intended.

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

採用された回答

Oddur Bjarnason
Oddur Bjarnason 2017 年 7 月 12 日
編集済み: Oddur Bjarnason 2017 年 7 月 12 日
Combining the suggestions of David and KSSV I believe that I have found a solution to my problem. I have been trying to write a simple script for computing a Fuzzy-Logic Cognitive Map. The script is as follows:
T=[0,1,-0.1,0.8,0;0,0,0,1,0;-0.2,-1,0,-0.2,0;0,0,0,0,0;0.2,0.5,-0.5,-0.2,0] ;
S0=[1,1,1,1,1] ;
n=0;
S1=zeros(5,length(T)) ;
S2=zeros(5,length(T)) ;
for n=1:5
S1(n,:)=S0*T^n
S2(n,:)=(1./(1 + exp(1).^(-1*S1(n,:))))
end
Thank you both..

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by