Differentiation of two variables in a polynomial equation
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
bayoishola20
el 17 de Feb. de 2015
Comentada: John D'Errico
el 17 de Feb. de 2015
Please the differential part gives giving me empty curly brackets instead of values in this code set.
% Initial x1 and x2
x1 = 5, x2 = 4
% Equations
y1 = (x1-3)^2 + (2*x2 - 8)^2
y2 =(x1-4)^2 + (x2 - 10)^2
%Given y values
y = [5;49]
% First set of y values
yo = [y1;y2]
f = y - yo
A11 = diff(poly((x1-3)^2 + (2*x2 - 8)^2),x1)
A12 =diff(poly((x1-3)^2 + (2*x2 - 8)^2),x2)
A21 =diff(poly((x1-4)^2 + (x2 - 10)^2),x1)
A22 =diff(poly((x1-4)^2 + (x2 - 10)^2),x2)
| I was expecting to see this: | http://www.mathworks.com/matlabcentral/answers/uploaded_files/25540/Capture.JPG
Thank you.
0 comentarios
Respuesta aceptada
John D'Errico
el 17 de Feb. de 2015
x1 and x2 are numbers. You set them as such. Remember this line?
x1 = 5, x2 = 4
you cannot differentiate with respect to a number.
2 comentarios
bayoishola20
el 17 de Feb. de 2015
Editada: bayoishola20
el 17 de Feb. de 2015
John D'Errico
el 17 de Feb. de 2015
I'd start with the statement
syms x1 x2
This tells MATLAB that these are symbolic variables, something that you can differentiate.
When you defined them instead as 5 and 4 respectively, you told MATLAB they were simple numbers, just constants.
Later on, IF you have a specific value to evaluate a derivative at, then you can use subs.
Oh, by the way, When you define the variable A11, this does not create the (1,1) element of the matrix A, just a scalar variable named A11. I think you need to learn about brackets, [], and how to concatenate things into an array. Thus, see what this does:
[1 2;3 4]
Más respuestas (0)
Ver también
Categorías
Más información sobre Assumptions 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!