how to programme transition matrix with matlab
59 次查看(过去 30 天)
显示 更早的评论
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 ?
1 个评论
回答(3 个)
Image Analyst
2020-12-26
编辑:Image Analyst
2020-12-26
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 个评论
azertazert azertazertazertazert
2020-12-26
I'm trying to plot a solution of two dimensional system in reality with matlab , and i=0.... +inf, j=0......+inf , but for exemple i and j are bounded i,=0...5, matlab give :
Assignment has more non-singleton rhs dimensions than non-singleton subscripts
when we trying the code ?
Image Analyst
2020-12-26
Well you said that all were matrices so A0, A1, and A2 are matrices. And T(i,j) is one element out of a matrix T, so it's a scalar. Thus A1 * T(i, j) is a matrix times a scalar, which is a matrix. That's the middle term of your sum, and the other terms are also matrixes, so the sum of all 3 is a matrix. Now you're trying to stuff that matrix into a single element at T(I, j). That won't work. Are you sure that "A0, A1 and A2 ( are all matrices )"??? If the A were scalars, everything would work out fine.
Image Analyst
2020-12-27
Then what I said stands. What is on the right hand side of the equals sign is a matrix, and you can't stuff a whole matrix into one element of a different matrix, unless that different matrix is a cell array.
azertazert azertazertazertazert
2020-12-27
thank's for help, but until now I need this idea to my work and I can't do this programme with my self any help and thank's a lot?
Image Analyst
2020-12-27
It would work if you replaced the A by A(i,j), like
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(i, j) * T(i-1, j-1) + ...
A1(i, j) * T(i, j-1) + ...
A2(i, j) * T(i-1, j);
end
end
T
Do you think that's what you want?
azertazert azertazertazertazert
2020-12-27
in this case we have A0 and A1 and A2 ares* the same case ( scalar coefficients not matrices) because the term T(i,j) is a matrix not coefficient ( scalar) that waht I have a problem
Image Analyst
2020-12-28
I'm not sure what "ares*" means.
If T is the name of a variable that is a matrix, then T(i,j) is one single number - a scalar, NOT a matrix.
Perhaps if you gave some more context by showing the paper above and below the equations it might explain more.
azertazert azertazertazertazert
2020-12-29
Hellow, my work based on the system
and it's solution for zero boundary condition is as follows x(t1,t2)=
that what how t plot this solution for A0 A1 A2 are latrices
azertazert azertazertazertazert
2020-12-29
with i and j are bouned for exemple i=0..20 j=0....20 and \alpha =0.8 and \beta =0.2
wassim bidi
2021-1-17
Excuse me ,i have a problem i can't ask
so, how do i solve this problem?
Error using plot
Vectors must be the same lengths
clc
clear
sys1 = tf(1,[0.1 1])
t=0:0.1:10;
step(sys1)
y=step(sys1);
plot(t,y)
Image Analyst
2021-1-17
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
2021-1-19
@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
Walter Roberson
2020-12-31
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 个评论
azertazert azertazertazertazert
2020-12-31
matlab v 2015 give
T
Conversion to double from cell is not possible.
Image Analyst
2020-12-31
You forgot to give the ENTIRE error message, which includes line numbers and the actual line of code.
The code Walter posted runs without error. I just tried it. How did you alter it?
azertazert azertazertazertazert
2020-12-31
编辑:azertazert azertazertazertazert
2020-12-31
Image Analysit In the previous (answer) and question I show the system and the solution that I want plot , the code of Walter runs without error.
Image Analyst
2020-12-31
Put it in a script/editor window, not on the command line.
Also put
clear all
because evidently you have another variable called T that is a double so doing
T(1, 1:n) = {eye(n)};
won't work because you're trying to put a cell into a double. Clearing everything will get rid of your prior T and let it work.
azertazert azertazertazertazert
2020-12-31
Thank , it work now like you and Walter say, but the last question how I can eca;uate T(1,2) for exemple matlab show me {7×7 double} I want the value of this matrix
Image Analyst
2020-12-31
I can tell you how to do that, but I'd rather you read the FAQ and learn how to do that:
azertazert azertazertazertazert
2020-12-31
Thank you a gain, I used cell2mat(T([4 5])) to extract the value of T(i,j) , Now when I'm tryin a noter exemple where i,j=2.....25 and we have small matrix for example A0=[1 2;3 4] we have a proble of dimension
Image Analyst
2020-12-31
OK, but you should have read the FAQ. If you had, you would know that you can simply use braces to extract the contents of a cell. This is how most MATLAB programmers would do it:
cellContents = T{1,2};
rather than call the cell2mat() function. The FAQ does not even mention cell2mat().
azertazert azertazertazertazert
2021-1-1
yes it work now, but If we wante change for simple example I wante chosse dimesnion of our matrix =2 and i=2:25 for example
clear all
n=2
A0 = [0.5 1 ;2 3];
A1 = [4 1 ;0.8 -2];
A2 = [3.4 1.2 ;-0.4 1];
T(1,1:n) = {eye(n)};
T(1:n,1) = {eye(n)};
for i = 2 : 25
for j = 2 : 25
T{i, j} = ...
A0 * T{i-1, j-1} + ...
A1 * T{i, j-1} + ...
A2 * T{i-1, j};
end
end
T
we will have a problem of Index exceeds matrix dimensions.
Image Analyst
2021-1-1
Of course. Because if A is a matrix and you're multiplying it by some matrix inside the cell of T, the number of columns of A must match the number of rows of whatever is inside that cell of T. Evidently it doesn't match.
azertazert azertazertazertazert
2021-1-1
any solution of this situation ????? if we have this case I want dim(A0)=2 or 3 for example and "i" and "j" are bouded max=25
Image Analyst
2021-1-1
That's what we've been trying to tell you. The original equation does not make sense if the A are matrices. The only suggestion I had to fix it was to index A with (i, j) so that you are using JUST ONE ELEMENT of A instead of the whole matrix.
azertazert azertazertazertazert
2021-1-1
yes I understood your idea, but there is some researchers studie this classe of system and they give the plot of solution for the considered system and A0 A1 A2 are matrices but how did they do this I don't Know , for this reason i ask questions
Walter Roberson
2021-1-1
If you want to iterate i and j to 25, then you must initialize T(1:1:25) and T(1:25,1)
n=2
n = 2
maxiter = 25;
A0 = [0.5 1 ;2 3];
A1 = [4 1 ;0.8 -2];
A2 = [3.4 1.2 ;-0.4 1];
T(1,1:maxiter) = {eye(n)};
T(2:maxiter,1) = {eye(n)};
for i = 2 : maxiter
for j = 2 : maxiter
T{i, j} = ...
A0 * T{i-1, j-1} + ...
A1 * T{i, j-1} + ...
A2 * T{i-1, j};
end
end
T
T = 25x25 cell array
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
{2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double} {2×2 double}
azertazert azertazertazertazert
2021-1-1
Thanks WAlter and Image Analyst now I can see some result that I need I will try other exemple and I will tele yous the results,
again thak you so much.
azertazert azertazertazertazert
2021-1-1
tha last question If I want plot the surface " x "
clc
maxiter = 25;
A0 = [0.5 1 ;2 3];
A1 = [4 1 ;0.8 -2];
A2 = [3.4 1.2 ;-0.4 1];
T(1,1:maxiter) = {eye(2)};
T(2:maxiter,1) = {eye(2)};
for i = 2 : maxiter
for j = 2 : maxiter
T{i, j} = ...
A0 * T{i-1, j-1} + ...
A1 * T{i, j-1} + ...
A2 * T{i-1, j};
end
end
T;
x=[0 0]';
B=[1 4]';
syms t1 t2
for i = 2 : maxiter
for j = 2 : maxiter
x=x+T{i,j}*B*t1^i*t2^j;
end
end
x depend on variable t1 t2 any solution to plot directly because It's long expression ?
Walter Roberson
2021-1-1
subplot(2,1,1)
fsurf(x(1), 0.9*[-1 1 -1 1])
xlabel('t1')
ylabel('t2')
title('first x')
subplot(2,1,2)
fsurf(x(2), 0.9*[-1 1 -1 1])
xlabel('t1')
ylabel('t2')
title('second x')
azertazert azertazertazertazert
2021-1-2
编辑:azertazert azertazertazertazert
2021-1-2
thank walter, excuse me for being late in a book the example
clc
maxiter = 25;
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];
T(1,1:maxiter) = {eye(2)};
T(2:maxiter,1) = {eye(2)};
for i = 2 : maxiter
for j = 2 : maxiter
T{i, j} = ...
A0 * T{i-1, j-1} + ...
A1 * T{i, j-1} + ...
A2 * T{i-1, j};
end
end
T;
x=[0 0]';
B=[0.1 0.1]';
syms t1 t2
alpha= 0.7;
beta=0.9;
for i = 2 : maxiter
for j = 2 : maxiter
x=x+T{i-1,j-1}*B*((t1^(i*alpha))/gamma(i*alpha+1))*((t2^(j*beta))/gamma(j*beta+1));
end
end
fsurf(x(1), [0 20 0 20])
xlabel('t1')
ylabel('t2')
title('first x')
the plot is shown
but in this code , my matlab don show me the plot a white page only and this message
Undefined function or variable 'fsurf'.
Error in Transition_matrix (line 35)
fsurf(x(1), 0.9*[-1 1 -1 1])
bu If Iuse matlab online It show me this plot !!!
azertazert azertazertazertazert
2021-1-2
编辑:azertazert azertazertazertazert
2021-1-2
and If I use In my matlab 2015 this code
ezsurf(x(2), [0 20 0 20])
xlabel('t1')
ylabel('t2')
title('first x')
it show
Perhaps we have a mistakes In the code because only T(0,0)= eye(2) in the first picture that contain the expression of T(i,j) not a cel .?
azertazert azertazertazertazert
2021-1-2
编辑:azertazert azertazertazertazert
2021-1-2
I have only matlab 2015, the command ezurf work but is note the same graphe ?
Walter Roberson
2021-1-2
The online version you plotted x(1), the ezsurf you plotted x(2). The plots are different
azertazert azertazertazertazert
2021-1-2
WAlter yes this ezsurf is the same as fsurf ??
and the last question why this graphe is note the same as in the originale paper
may be there a simple mistakes in the programme in the beginig
because it must T(0,0)=eye(2) or in this case T(1,1) =eye(2) not all tha cell
T(1,1:maxiter) = {eye(2)};
T(2:maxiter,1) = {eye(2)}; ??????
Walter Roberson
2021-1-3
I did identify a problem in the initialization but I have not had time to write it up yet... been dealing with hardware problems
Walter Roberson
2021-1-3
maxiter = 25;
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];
%corrected initialization
T{1,1} = eye(2);
for i = 2 : maxiter
T{i,1} = A2*T{i-1,1};
end
for j = 2 : maxiter
T{1,j} = A1*T{1,j-1};
end
%do the work
for i = 2 : maxiter
for j = 2 : maxiter
T{i, j} = ...
A0 * T{i-1, j-1} + ...
A1 * T{i, j-1} + ...
A2 * T{i-1, j};
end
end
x=[0 0]';
B=[0.1 0.1]';
syms t1 t2
alpha= 0.7;
beta=0.9;
for i = 2 : maxiter
for j = 2 : maxiter
x=x+T{i-1,j-1}*B*((t1^(i*alpha))/gamma(i*alpha+1))*((t2^(j*beta))/gamma(j*beta+1));
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')
azertazert azertazertazertazert
2021-1-3
Thank you walter and Paul for helping me, Now It should be work but we have to find this graph
Paul
2021-1-3
Can you post a screen capture of the equation for x from the source, like you did for T(i,j)?
Walter Roberson
2021-1-3
Here is an implementation of T as a recursive function, to ensure that the proper thing is being calculated.
Note that in this implementation, what is to be passed to T is the zero-based indices exactly as in the definition of .
But please be sure to check the bounds of iteration of i and j, keeping in mind that for this purpose it is fine to pass 0 to T. In particular, check what the powers of t1 should be in the variable ti, and the powers of t2 should be in the variable tj, and how those power relate to the (zero based) indices to pass into T.
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 = 1 : maxiter
ti = B * ((t1^(i*alpha))/gamma(i*alpha+1));
for j = 1 : 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
2021-1-3
firs the system is:
the solution is defined as follow
for a bounded i and j by 25 we have
for example :
the solution is given in the previous picture and T(i,j)
the plot of solution is
and Thank a gain Paul
azertazert azertazertazertazert
2021-1-3
Walter Roberson thak you thak you thank you it work perfectly 100 % ,!!!
Walter Roberson
2021-1-3
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
2021-1-3
yes walter you are right about the power should be begin from zero
azertazert azertazertazertazert
2021-1-3
Thank' Walter I will wait when you have time to write to me , thank you again
1 个评论
azertazert azertazertazertazert
2021-1-6
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')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
标签
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)