I cannot remove 0 elements of a symbolic array
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Mohammad Shojaei Arani
el 1 de Feb. de 2022
Comentada: Mohammad Shojaei Arani
el 1 de Feb. de 2022
Hello friends!
Consider the following commands
syms x sigma(x)
par=sym('par%d', [1 2],'positive');
sigma(x)=par(1)+par(2)*x;
D_sigma=[sigma diff(sigma) diff(sigma,2) diff(sigma,3)];
D_sigma
nonzeros(D_sigma)
D_sigma(x) =
[par1 + par2*x, par2, 0, 0]
ans(x) =
[par1 + par2*x, par2, 0, 0]
I really have no idea why this does not work!!!!!!!
Any help!
Thanks in advance!
Babak
0 comentarios
Respuesta aceptada
Walter Roberson
el 1 de Feb. de 2022
syms x sigma(x)
par=sym('par%d', [1 2],'positive');
sigma(x)=par(1)+par(2)*x;
D_sigma=[sigma diff(sigma) diff(sigma,2) diff(sigma,3)];
D_sigma
DSX = D_sigma(x);
nonzeros(DSX)
The reason you had a problem is that your D_sigma is a symbolic function, not a vector.
3 comentarios
Walter Roberson
el 1 de Feb. de 2022
Your D_sigma was a single function that returns a vector. The function itself is not zero, so nonzeros() does not remove the function.
You should not think of your D_sigma as being a vector of functions. It cannot be indexed into. It is a 1 x 1 object that happens to return a vector (whos size depends upon the input). [Huh, it can return a cell array???)
syms x sigma(x)
par=sym('par%d', [1 2],'positive');
sigma(x)=par(1)+par(2)*x;
D_sigma=[sigma diff(sigma) diff(sigma,2) diff(sigma,3)]
D_sigma([-1 1])
Más respuestas (0)
Ver también
Categorías
Más información sobre Number Theory en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!