finding magnitude of a vector (2024)

18visualizaciones (últimos 30días)

Mostrar comentarios más antiguos

Ashlianne Sharma el 7 de Nov. de 2020

  • Enlazar

    Enlace directo a esta pregunta

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector

  • Enlazar

    Enlace directo a esta pregunta

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector

Comentada: Ashlianne Sharma el 8 de Nov. de 2020

Abrir en MATLAB Online

Hi all, I am trying to make a function and the first step within my function is to find the magnitude of a vector that I have named on another script. How do I do this? I willo put my code below to explain more.

FROM FUNCTION PAGE

function[a, e, nu, i, O, m] = hw_COE_sharmaAshlianne(R, V)

% Inputs

% R = Radius vector [km]

% V = Velocity vector [km/s]

%

% Outputs

% a = semi major axis [km]

% e = eccentricity [no units]

% nu = true anomoly [degrees]

% i = inclination [degrees]

% O = right ascention of the ascending node(RAAN) [degrees]

% w = argument of perigee [degrees]

% Known values

m = 398600; % [km^3/s^2]

% Step one find the magnitude of the radius and velocity vectors

r = norm(R);

v = norm(V);

FROM SCRIPT

% Create a structure for our function to find COE parameters

Rvector = [15370 1400 21950]; % [km]

Vvector = [-0.1 3.84 -0.2]; % [km/s]

% Call function with the structured variables we created above

[a, e, nu, i, O, m] = hw_COE_sharmaAshlianne(Rvector, Vvector);

so to reiterate my question, how do I find the magnitude of Rvector that is defined in my script on my function page (STEP ONE IN FUNCTION)

16 comentarios

Mostrar 14 comentarios más antiguosOcultar 14 comentarios más antiguos

VBBV el 7 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117465

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117465

Editada: Walter Roberson el 8 de Nov. de 2020

Abrir en MATLAB Online

>> hw_COE_sharmaAshlianne([...],[...])

Go to the command window and enter the vectors as shown above. Alternately run the script file in which the you are calling the function hw_COE_sharmaAshlianne(Rvector,Vvector)

Ashlianne Sharma el 7 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117525

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117525

Abrir en MATLAB Online

I have done that, I made the separate script by which I call my function with

[a, e, nu, i, RAAN, w] = hw_COE_sharmaAshlianne(Rvector, Vvector);

just as I stated in my original question.

Again, the question I asked is how do I code to find the magnitude of the vector because as I put above, it does not work. I would appreciate if you help me with the question I asked??

r = norm(R);

v = norm(V);

I tried putting the lines

r = Rvector;

but that does not work.

VBBV el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117585

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117585

Editada: Walter Roberson el 8 de Nov. de 2020

Abrir en MATLAB Online

Since norm calculates the magnitude of the vector and is defined inside the function as

function[a,e,nu,i,O,m]=

w_COE_sharmaAshlianne(Rvector,Vvector)

...

r = norm(Rvector);

v = norm(Vvector)

...

end % close function file with end statement

Close function file with end

Ashlianne Sharma el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117675

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117675

Okay that makes a lot of sense! I am still running into an issue here at these lines of code. The error message I am getting it that I don't have enough input arguments (regarding my Rvector and Vvector).

In order for me to define the Rvector and the Vvector on my script, how do I get those values onto my function page?

I don't know if I am making sense haha, I guess what I am trying to say is how do I call a function with specific values that will run through my function page if I dont explicitely define the R and V vectors on my function page?

VBBV el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117700

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117700

Editada: VBBV el 8 de Nov. de 2020

In function page just define the same variable vectors as defined in script file as shown in my message. Inside the function you don't require or have to define R and V again. Instead you pass the vectors Rvector and Vvector as arguments and use them with norm

VBBV el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117710

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117710

If you delete the semicolon at the

norm(Rvector) norm(Vvector)

You can see the values of magnitude in command window once the run is completed .

Ashlianne Sharma el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117725

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117725

Okay, so you had an amzing explaination for the norm aspect, thank you so much.

This question seems simple, But I struggle with this since the start of the class.

Script %note I changed Rvector to R for simplicity

% Define given vectors as variables

R = [15370 100 21950]; % [km]

V = [-0.1 3.84 -0.2]; % [km/s]

% Call function with the structured variables we created above

[a, e, nu, i, RAAN, w] = hw_COE_sharmaAshlianne(R, V);

Function: line one, after this line, I finished the rest of my code.

function[a, e, nu, i, RAAN, w] = hw_COE_sharmaAshlianne(R, V)

Question:

When I was getting your help, I just defined my vectors inside my function. Like you say above, you dont need to do this. I took out my defined vectors from my function and I now get an error message saying I do not have enough input arguments. I don't know how to pass the variables through. Like I know the variables have to be the same on the script and function page, But that isnt working for me. Any explaination on passing variables through the function would be great help... The matlab version online hasnt been too much of help. Thank you Vasishta!

VBBV el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117745

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117745

Did you name the file exactly the same as function name? I.e. the name of the file which contains your function code and name of the function must be same. The name of file in which function code is present must be

hw_COE_sharmaAshlianne.

If you name something else then it will not run.

Ashlianne Sharma el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117750

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117750

yeah I saved the file as the same name as my function. Everything was working until I removed the R and V vectors from the function file

Ashlianne Sharma el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117755

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117755

So when I run my script that I call my function on, it works perfectly, however, I when I run my function file, i get the message that there are not enough input arguments

VBBV el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117760

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117760

Oh. You seem to have changed the names of variables Rvector and Vvector in your script file from which you're calling function. Change it to

Rvector = [values] Vvector = [values]

VBBV el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117770

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117770

Editada: VBBV el 8 de Nov. de 2020

Abrir en MATLAB Online

Keep the same structure like before in the first post.

% if true

% code

% end

Rvector = [15370 1400 21950]; % [km]

Vvector = [-0.1 3.84 -0.2]; % [km/s]

%

[a, e, nu, i, O, m] = hw_COE_sharmaAshlianne(Rvector, Vvector);

VBBV el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117775

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117775

Rvector, Vvector must have same names in script file and function file

Ashlianne Sharma el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117790

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117790

okay, that makes sense. Just so I am understanding,

script

Rvector = [15370 1400 21950]; % [km]

Vvector = [-0.1 3.84 -0.2]; % [km/s]

%

[a, e, nu, i, O, m] = hw_COE_sharmaAshlianne(Rvector, Vvector);

Function

function[a, e, nu, i, RAAN, w] = hw_COE_sharmaAshlianne(Rvector, Vvector)

and everywhere in my code that R and V exist in my function, the variable should be Rvector and Vvector aswell?

VBBV el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117800

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117800

Editada: VBBV el 8 de Nov. de 2020

Abrir en MATLAB Online

https://in.mathworks.com/help/matlab/ref/function.html

Check the syntax of function declaration. You require space between the word function and output variable vector

%if true

% code

%end

function [a,e,nu,i,O,m]=

w_COE_sharmaAshlianne(Rvector,Vvector)

...

r = norm(Rvector);

v = norm(Vvector)

...

end % close function file with end statement

Ashlianne Sharma el 8 de Nov. de 2020

Enlace directo a este comentario

https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117815

  • Enlazar

    Enlace directo a este comentario

    https://la.mathworks.com/matlabcentral/answers/639990-finding-magnitude-of-a-vector#comment_1117815

Okay, Thank you so much for your help!! i will definitely look more to the page you sent me, I think that may be very useful. Again, Thank you so much for taking So SO much time out to help me. I am just a struggling college student haha but yes, I really appreciate your time and help Vasishta!

Iniciar sesión para comentar.

Iniciar sesión para responder a esta pregunta.

Respuestas (0)

Iniciar sesión para responder a esta pregunta.

Ver también

Categorías

MATLABLanguage FundamentalsMatrices and ArraysMatrix Indexing

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

  • magnitude of vector
  • norm(r)

Community Treasure Hunt

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

Start Hunting!

Se ha producido un error

No se puede completar la acción debido a los cambios realizados en la página. Vuelva a cargar la página para ver el estado actualizado.


Translated by finding magnitude of a vector (18)

finding magnitude of a vector (19)

Seleccione un país/idioma

Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .

También puede seleccionar uno de estos países/idiomas:

América

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europa

  • 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
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia-Pacífico

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Comuníquese con su oficina local

finding magnitude of a vector (2024)

FAQs

Finding magnitude of a vector? ›

Thus, the formula to determine the magnitude of a vector (in two-dimensional space) v = (x, y) is: |v| =√(x2 + y2). This formula is derived from the Pythagorean theorem. the formula to determine the magnitude of a vector (in three-dimensional space) V = (x, y, z) is: |V| = √(x2 + y2 + z2)

What is the magnitude of that vector? ›

The magnitude of a vector is the length of the vector. The magnitude of the vector a is denoted as ∥a∥. See the introduction to vectors for more about the magnitude of a vector. Formulas for the magnitude of vectors in two and three dimensions in terms of their coordinates are derived in this page.

What is the magnitude of 3i 4j? ›

The correct option is C 5 units.

How do you find the magnitude and direction of a vector? ›

How to Calculate a Vector's Magnitude and Direction from its Components. Step 1: Use the equation A = A x 2 + A y 2 to calculate the magnitude of the vector. Step 2: Use the equation Θ = tan − 1 ⁡ ( A y A x ) to calculate the direction of the vector.

What is the formula for the magnitude of vector A? ›

Various formulas are used to calculate the magnitude of the vector some of them are, |A| = √(x2 + y2 + z2) when the vector is in the form of A = xi + yj + zk. |A| = √((x)2 + (y)2) when the vector is given by point A (x, y) and the origin O(0, 0).

What is the magnitude of a vector → p 3 i − 4 j? ›

Magnitude, |→P|=√32+(−4)2=5.

What is the magnitude of the vector 3 4i? ›

Answer and Explanation:

We get that the magnitude of 3 + 4i is 5.

What is the magnitude of the vector a 3j 4j? ›

Therefore the magnitude of the vector 3i +4j, is 5 units.

How to calculate the magnitude of resultant force? ›

Two forces that act in opposite directions produce a resultant force. If all the forces are balanced, the resultant force is zero. that is smaller than either individual force. To find the resultant force subtract the magnitude of the smaller force from the magnitude of the larger force.

Is magnitude always positive? ›

Answer: Magnitude cannot be negative. It is the length of the vector which does not have a direction (positive or negative). In the formula, the values inside the summation are squared, which makes them positive.

Do vectors have direction or magnitude? ›

Vectors have magnitude and direction, scalars only have magnitude. The fact that magnitude occurs for both scalars and vectors can lead to some confusion. There are some quantities, like speed, which have very special definitions for scientists. By definition, speed is the scalar magnitude of a velocity vector.

What is the formula for the magnitude of a vector product? ›

Vector product also means that it is the cross product of two vectors. If you have two vectors a and b then the vector product of a and b is c. So this a × b actually means that the magnitude of c = ab sinθ where θ is the angle between a and b and the direction of c is perpendicular to a well as b.

How do you find the magnitude of a unit vector? ›

The magnitude of a vector. For a given vector with the direction along the x-axis, y-axis, and z-axis, the magnitude of the vector can be obtained by calculating the square root of the sum of the squares of its direction ratios.

How to find the magnitude of a vector product? ›

The vector product of two vectors is a vector perpendicular to both of them. Its magnitude is obtained by multiplying their magnitudes by the sine of the angle between them. The direction of the vector product can be determined by the corkscrew right-hand rule.

How to find the magnitude of a unit vector? ›

The magnitude of a vector. For a given vector with the direction along the x-axis, y-axis, and z-axis, the magnitude of the vector can be obtained by calculating the square root of the sum of the squares of its direction ratios.

How to find the magnitude of 3 vectors? ›

Answer: The magnitude of a 3-dimensional vector with 3 components V = (a, b, c) is given as √(a2 + b2 + c2).

What is the magnitude of the area vector? ›

By definition, the magnitude of vector area of a plane is equal to the area of the plane and has a direction, parallel to the direction of the normal of the plane, i.e. perpendicular to the plane.

References

Top Articles
Brian Wilson Baskin Louisiana
Kentucky Fried Chicken Online Menu
5 Fastest Ways To Become Rich by Investing in the Stock Market
Espn Transfer Portal Basketball
Caremount Medical Flu Shots 2022
6 Underground movie review & film summary (2019) | Roger Ebert
Jocko Joint Warfare Review
Edgenuity Answer Key Algebra 1 Pdf
Babylon Showtimes Near Airport Stadium 12
Guardians Of The Galaxy Vol 3 Full Movie 123Movies
Things to do in Wichita Falls on weekends 12-15 September
19 Dollar Fortnite Card Copypasta
Getwush Com
Finger Lakes 1 Police Beat
Cratebrowser
Eggy Car Unblocked - Chrome Web Store
Black Ballerina Michaela Mabinty DePrince morreu aos 29 anos
Bank Hours Saturday Chase
Chicken Coop Brookhaven Ms
Sloansmoans Bio
Bootyandthebeast69 Swap
Robert Rushing Net Worth, Daughter, Age, and Wikipedia
Sas Majors
Craigslist For Cars Los Angeles
Pain Out Maxx Kratom
Dumb Money Showtimes Near Regal Edwards Nampa Spectrum
Watch Fifty Shades Darker Online Putlocker
3 30 Mountain Time
Natasha Tillotson
Espn College Basketball Scores
Seanna: meaning, origin, and significance explained
Ihub Kblb
David Goggins Is A Fraud
Premium Car Rental in Vancouver
9132976760
Sentara Norfolk General Visiting Hours
ACMG - American College of Medical Genetics and Genomics on LinkedIn: #medicalgenetics #genomics
Imperialism Flocabulary Quiz Answers
Riverry Studio
Duluth Craigslist Boats
10000 Divided By 5
Uc Davis Tech Management Minor
6173770487
Alles, was ihr über Saison 03 von Call of Duty: Warzone 2.0 und Call of Duty: Modern Warfare II wissen müsst
Beauty TikTok Star Mireya Rios' Magical Wedding on the Beaches of Mexico
Carter Williamson Jay Ok
Dean of Students | Alcohol & Drug Policies
Roblox Mod Menu Platinmods
Thekat103.7
'It's something you dream about': This sparky quit his job to be a YouTube star
Stuckey Furniture
8X10 Meters To Square Meters
Latest Posts
Article information

Author: Dong Thiel

Last Updated:

Views: 6220

Rating: 4.9 / 5 (79 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Dong Thiel

Birthday: 2001-07-14

Address: 2865 Kasha Unions, West Corrinne, AK 05708-1071

Phone: +3512198379449

Job: Design Planner

Hobby: Graffiti, Foreign language learning, Gambling, Metalworking, Rowing, Sculling, Sewing

Introduction: My name is Dong Thiel, I am a brainy, happy, tasty, lively, splendid, talented, cooperative person who loves writing and wants to share my knowledge and understanding with you.