syms z x a v
Y(1)=a
T=0
for k=1:2
Y(k+1)=z
v=0
for l=1:k
v=v+kroneckerDelta(sym(l-2))*(k+2-l)*(k+1-l)*Y(k+2-l) % THIS LINE
end
T= v+ 2*(k)*Y(k+1)+(kroneckerDelta(sym(l-2)))==0
a=solve(T,z)
Y(k+1)=a
end
The highlighted part is not getting updated. Why it is so? Y(2)=z is variable and this value is later used to calculate T.

Réponses (1)

VBBV
VBBV le 4 Jan 2023

1 vote

syms z x a v
Y(1)=a
T=0
for k=1:2
Y(k+1)=z;
v=0;
for l=1:k
v=v+kroneckerDelta(str2sym('l-2'))*(k+2-l)*(k+1-l)*Y(k+2-l);
end
T= v+ 2*(k)*Y(k+1)+(kroneckerDelta(str2sym('l-2')))==0
a=solve(T,z);
Y(k+1)=a;
end

6 commentaires

VBBV
VBBV le 4 Jan 2023
Use str2sym
yogeshwari patel
yogeshwari patel le 5 Jan 2023
Sir You did get my point .Let me explain it
(kroneckerDelta(('l-2')) part is correct as the value of l varies from 1 to n the answer are 0,1,0,0,0,...... Now in the first for loop when value of l=2 , kroneckerDelta(('l-2') is one and Y(k+2-l)=z .So value that must be stored in variable v= 2z but after each and every calculation it is zero. That is the problem with the code
You're assigning a to Y, not z. What is the point of z? What value does z even have? If you do
whos z
z
as the first lines in your for loop, what does it show?
yogeshwari patel
yogeshwari patel le 5 Jan 2023
I want to generate the linear equation see I have check the calculation but is not correct
syms z x a v
Y(1)=a
T=0
fprintf('&&&&&&&&&')
for k=1:2
Y(k+1)=z
v=0;
for l=1:k
t=kroneckerDelta(sym(l-2))
m=Y(k+1)
y=Y(k+2-l)
n=(k+2-l)*(k+1-l)*Y(k+2-l)
v=v+kroneckerDelta(sym(l-2))*(k+2-l)*(k+1-l)*Y(k+2-l)
end
T= v+ 2*(k)*Y(k+1)+(kroneckerDelta(sym(l-2)))==0
a=solve(T,z);
Y(k+1)=a
fprintf('%%%%%%%%%%%%%%%%%%%%%5')
end
syms z x a v
Y(1)=a
Y = 
a
T=0;
for k=1:2
Y(k+1)=z
v=0
for l=1:k
v=v+kroneckerDelta(sym(l-2))*(k+2-l)*(k+1-l)*Y(k+2-l) % THIS LINE
end
T= v+ 2*(k)*Y(k+1)+(kroneckerDelta(sym(l-2)))==0
a=solve(T,z)
Y(k)=a % may be this is change needed
end
Y = 
v = 0
v = 
0
T = 
a = 
0
Y = 
Y = 
v = 0
v = 
0
v = 
T = 
a = 
Y = 
VBBV
VBBV le 5 Jan 2023
Modifié(e) : VBBV le 5 Jan 2023
you need to assign kth value to a in the below line
a=solve(T,z)
Y(k)=a % may be this is change needed
end

Connectez-vous pour commenter.

Catégories

En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by