How can I calculate the length of a vector, if x and y of a vector are both in formula form?
95 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Tianze Li
le 15 Mai 2019
Réponse apportée : Image Analyst
le 25 Mai 2019
Here is the requirement for coding, first line of coding is the range of x and y, vecyx is dL/dx, vecy is dL/dy. Those are provided by the requriement.
Then following the requirement's description. I used V=[ ] ; length(v) to calculate the length, but it just come up one result. But according to the description, the reulst should be an array. So how do i code it? Many thanks!!!!!!
[x,y]=meshgrid(0:0.01:50, 0:0.01:30);
vecx=((2*x-30)/(2*sqrt(850-30*x-50*y+x.^2+y.^2))+((2*x-20)/(2*sqrt(125-20*x-10*y+x.^2+y.^2)))+((2*x-80)/(2*sqrt(1700-80*x-20*y+x.^2+y.^2))));
vecy=((2*y-50)/(2*sqrt(850-30*x-50*y+x.^2+y.^2))+((2*y-10)/(2*sqrt(125-20*x-10*y+x.^2+y.^2)))+((2*y-20)/(2*sqrt(1700-80*x-20*y+x.^2+y.^2))));
V=[vecx vecy];
L=length(V);
0 commentaires
Réponse acceptée
Image Analyst
le 25 Mai 2019
The v is a vector, and the question wants the length of v but not in elements, but in real world units. For example if my vx was [1,2] and my vy was [1,2] then my length in elements would be 2 because length(vx) = 2, however my length of my x is sqrt(2) - the length of the vector going from (1,1) to (2,2). So what you need to do to compute the length along your v vector is summing along all the delta v from one element to the next. See if you can use diff() and sqrt() and sum() to do that.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Special Functions dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!