how to programme transition matrix with matlab

77 Ansichten (letzte 30 Tage)
azertazert azertazertazertazert
Kommentiert: Kent Millard am 19 Jan. 2021
In dynamical system ( two dimensional ) we have transition matrix for a given A0, A1 and A2 ( are all matrices )
how we can programme this matrix with matlab ?

Antworten (3)

Image Analyst
Image Analyst am 26 Dez. 2020
Bearbeitet: Image Analyst am 26 Dez. 2020
It looks like they're starting with i and j of zero so you need to skip the first row. Did you try eye() and a simple for loop?
n = 7;
A0 = 1 * rand(n)
A1 = 10 * rand(n)
A2 = 100 * rand(n)
T = eye(n)
for i = 2 : n
for j = 2 : n
T(i, j) = ...
A0 * T(i-1, j-1) + ...
A1 * T(i, j-1) + ...
A2 * T(i-1, j);
end
end
T
Note that it fails because we're taking matrices (the right hand side of the equation) and trying to stuff a matrix into a single element (the element at row i and column j), which you can't do. I think you need to explain it better.
And regarding your tags, what does this have to do with image analysis or processing?
  15 Kommentare
Image Analyst
Image Analyst am 17 Jan. 2021
wassim, yes you CAN ask, and you just did. However you asked in the wrong place. You asked in azertazert's discussion instead of starting your own. Once you start your own, people will be able to tell you why t is not the same length as y, like ask you why you didn't define t as linspace(0, 10, length(y)).
Kent Millard
Kent Millard am 19 Jan. 2021
@wassim bidi Hi Wassim. If you're still interested in asking your question, please click the 'Ask' link beneath the blue bar or use this link to start a new question thread. Best - Kent

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 31 Dez. 2020
n = 7;
A0 = 1 * rand(n);
A1 = 10 * rand(n);
A2 = 100 * rand(n);
T(1,1:n) = {eye(n)};
T(1:n,1) = {eye(n)};
for i = 2 : n
for j = 2 : n
T{i, j} = ...
A0 * T{i-1, j-1} + ...
A1 * T{i, j-1} + ...
A2 * T{i-1, j};
end
end
T
T = 7x7 cell array
{7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double} {7×7 double}
  32 Kommentare
Walter Roberson
Walter Roberson am 3 Jan. 2021
I was right in my previous concern: you do want to start the powers with 0.
A0 = [-0.1 0 ;0.1 -0.05];
A1 = [-0.01 0.1; 0.1 -0.05];
A2 = [-0.05 0;0.1 -0.01];
maxiter = 25;
x=[0 0]';
B=[0.1 0.1]';
syms t1 t2
alpha = 0.7;
beta = 0.9;
for i = 0 : maxiter
ti = B * ((t1^(i*alpha))/gamma(i*alpha+1));
for j = 0 : maxiter
tb = T(i-1, j-1, A0, A1, A2);
tj = ((t2^(j*beta))/gamma(j*beta+1));
x = x + tb * ti * tj;
end
end
fsurf(x(1), [0 20 0 20])
xlabel('t1')
ylabel('t2')
title('first x')
fsurf(x(2), [0 20 0 20])
xlabel('t1')
ylabel('t2')
title('second x')
function Tij = T(i, j, A0, A1, A2)
persistent tij Z
if isempty(tij);
tij = {eye(size(A0))};
Z = zeros(size(A0));
end
if i < 0 || j < 0
Tij = Z;
elseif i + 1 <= size(tij,1) && j+1 <= size(tij,2) && ~isempty(tij{i+1,j+1})
%i, j, size(tij)
Tij = tij{i+1,j+1};
else
ta0 = T(i-1, j-1, A0, A1, A2);
ta1 = T(i, j-1, A0, A1, A2);
ta2 = T(i-1, j, A0, A1, A2);
Tij = A0 * ta0 + A1 * ta1 + A2 * ta2;
tij{i+1, j+1} = Tij;
end
end
azertazert azertazertazertazert
yes walter you are right about the power should be begin from zero

Melden Sie sich an, um zu kommentieren.


azertazert azertazertazertazert
Thank' Walter I will wait when you have time to write to me , thank you again
  1 Kommentar
azertazert azertazertazertazert
Hellow, WALter If You can help me for the last time
I a similar problem that I want how to plot and obtain the same solution that exist :
1-------- the system:
2- The solution is as follow
with T(i,j) is :
fo example
the plot must be :
but I'm havn't this graphIn my plot.
The modified programme is:
function Tij = T(i, j, A1, A2)
persistent tij Z
if isempty(tij);
tij = {eye(size(A1))};
Z = zeros(size(A1));
end
if i < 0 || j < 0
Tij = Z;
elseif i + 1 <= size(tij,1) && j+1 <= size(tij,2) && ~isempty(tij{i+1,j+1})
%i, j, size(tij)
Tij = tij{i+1,j+1};
else
ta1 = T(i, j-1, A1, A2);
ta2 = T(i-1, j, A1, A2);
Tij = A1 * ta1 + A2 * ta2;
tij{i+1, j+1} = Tij;
end
end
clear all
clc
%exmple1
A1 = [-0.1 0; 0.1 -0.05];
A2 = [-0.01 0.1;0.1 -0.05];
maxiter = 25;
x=[0 0]';
%exmple1
B1=[-0.05 0.01]';
B2=[-0.1 -0.1]';
syms t1 t2
alpha = 0.7;
beta = 0.9;
for i = 1 : maxiter
ti = ((t1^(i*alpha))/gamma(i*alpha+1));
ti1 = ((t1^((i+1)*alpha))/gamma((i+1)*alpha+1));
for j = 1 : maxiter
tb1 = T(i, j, A1, A2);
tb2 = T(i-1, j, A1, A2);
tb3 = T(i, j-1, A1, A2);
tj = ((t2^(j*beta))/gamma(j*beta+1));
tj1 = ((t2^((j+1)*beta))/gamma((j+1)*beta+1));
x = x + (-tb1*B1*ti*tj1 -tb1*B2*ti1*tj)+ (tb3*B1+tb2*B2)*ti*tj;
end
end
ezsurf(x(1), [0 20 0 20])
xlabel('t1')
ylabel('t2')
title('first x')

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte


Version

R2015b

Community Treasure Hunt

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

Start Hunting!

Translated by