finding magnitude of a vector (2024)

20 Ansichten (letzte 30 Tage)

Ältere Kommentare anzeigen

Ashlianne Sharma am 7 Nov. 2020

  • Verknüpfen

    Direkter Link zu dieser Frage

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

  • Verknüpfen

    Direkter Link zu dieser Frage

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

Kommentiert: Ashlianne Sharma am 8 Nov. 2020

In MATLAB Online öffnen

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 Kommentare

14 ältere Kommentare anzeigen14 ältere Kommentare ausblenden

VBBV am 7 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

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

Bearbeitet: Walter Roberson am 8 Nov. 2020

In MATLAB Online öffnen

>> 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 am 7 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

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

In MATLAB Online öffnen

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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

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

Bearbeitet: Walter Roberson am 8 Nov. 2020

In MATLAB Online öffnen

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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

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

Bearbeitet: VBBV am 8 Nov. 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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

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

Bearbeitet: VBBV am 8 Nov. 2020

In MATLAB Online öffnen

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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

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

Bearbeitet: VBBV am 8 Nov. 2020

In MATLAB Online öffnen

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 am 8 Nov. 2020

Direkter Link zu diesem Kommentar

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

  • Verknüpfen

    Direkter Link zu diesem Kommentar

    https://de.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!

Melden Sie sich an, um zu kommentieren.

Melden Sie sich an, um diese Frage zu beantworten.

Antworten (0)

Melden Sie sich an, um diese Frage zu beantworten.

Siehe auch

Kategorien

MATLABLanguage FundamentalsMatrices and ArraysMatrix Indexing

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

  • magnitude of vector
  • norm(r)

Community Treasure Hunt

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

Start Hunting!

Es ist ein Fehler aufgetreten

Da Änderungen an der Seite vorgenommen wurden, kann diese Aktion nicht abgeschlossen werden. Laden Sie die Seite neu, um sie im aktualisierten Zustand anzuzeigen.


Translated by finding magnitude of a vector (18)

finding magnitude of a vector (19)

Website auswählen

Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .

Sie können auch eine Website aus der folgenden Liste auswählen:

Amerika

  • 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)

Asien-Pazifik

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

Kontakt zu Ihrer lokalen Niederlassung

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 a vector? ›

The magnitude of a vector P Q → is the distance between the initial point and the end point . In symbols the magnitude of P Q → is written as | P Q → | . If the coordinates of the initial point and the end point of a vector is given, the Distance Formula can be used to find its magnitude.

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

Therefore the magnitude of the vector 3i +4j, is 5 units. This statement can be mathematically written as: |3i+4j| = 5.

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 to find magnitude in 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)

How do you find the magnitude of a vector given its components? ›

Finding the Magnitude of a Vector Given in Component Form

Step 1: For a vector , fill in and in the formula | v | = a 2 + b 2 . Step 2: Simplify the magnitude | v | = a 2 + b 2 by simplifying underneath the square root first, and then simplifying the square root as much as possible.

Are magnitude and resultant the same? ›

A resultant is a vector. Specifically a vector sum of vectors. A magnitude is a property of a vector. It is a scalar, not a vector itself.

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

What is the Formula For the Addition of Vectors? This is the addition of vectors formula: Given two vectors a = (a1, a2) and b = (b1, b2), then the vector sum is, M = (a1 + b1, a2 + b2) = (Mx, My). In this case, magnitude of the resultant vector sum M = |M| = √ ((Mx)2+(My)2) and.

What is the formula for magnitude of the resultant acceleration? ›

Formulas for calculating resultant acceleration

A = ( A x ) 2 + ( A y ) 2 . Or its angle with respect to the y-axis, θ y = arctan ⁡ A x A y . Now, using these steps and formulas we work through several example problems for finding an object's resultant acceleration.

What is the formula of magnitude of unit vector? ›

A unit vector can be defined as a vector whose magnitude is of unit length. The length of unit vectors is always 1 and is commonly used to indicate the direction of a vector. If →x is a vector whose magnitude is x, then unit vector of →x in the direction of x is denoted by ˆx and is defined as ˆx=→x|ˆx|.

What is the magnitude multiplied by a vector? ›

A quantity that has magnitude but no direction to be specified is a scalar. Work is an example for a scalar. A vector can be multiplied by a number, a scalar and a vector. Multiplying a vector by a number results in a vector whose magnitude is the number times the vector.

How to find the magnitude of AxB? ›

Magnitude: |AxB| = A B sinθ. Just like the dot product, θ is the angle between the vectors A and B when they are drawn tail-to-tail. Direction: The vector AxB is perpendicular to the plane formed by A and B.

What do we mean by magnitude? ›

In physics, magnitude is defined simply as “distance or quantity.” It depicts the absolute or relative direction or size in which an object moves in the sense of motion. It is used to express the size or scope of something. In physics, magnitude generally refers to distance or quantity.

Is the magnitude of a vector always positive? ›

Since squares of real numbers are always non-negative, and the square root of a non-negative number is also non-negative, the magnitude of a vector is always a positive value or zero.

Is the magnitude of a vector squared? ›

Summary. The magnitude a vector is given by the square root of the sum of each of the components squared. Geometrically, the magnitude of a vector is equal to the length of the vector.

Does magnitude mean distance? ›

Magnitude generally refers to the quantity or distance. In relation to the movement, we can correlate magnitude with the size and speed of the object while travelling. The size of the object or the amount is its magnitude.

Top Articles
Breckie Hill: The Rise And The Leak That Shook Social Media
Unraveling The Mystery: Where Is Breckie Hill From?
Sarah Burton Is Givenchy's New Creative Director
NO CLUE: deutsche Übersetzung von NCT 127
Ohio State Football Wiki
Review: Chained Echoes (Switch) - One Of The Very Best RPGs Of The Year
Paulding County Bus Stop Locator
Main Moon Ashland Ohio Menu
Mychart.texaschildrens.org.mychart/Billing/Guest Pay
Understanding British Money: What's a Quid? A Shilling?
Exploring the Northern Michigan Craigslist: Your Gateway to Community and Bargains - Derby Telegraph
The 8 Best Santa Ynez Wineries to Visit in 2023
Does Teddy Swims Have A Wife? Exploring The Life Of The Rising Star
Hallmark White Coat Ceremony Cards
Cognitive Function Test Potomac Falls
How to find cash from balance sheet?
Craigslist Boats Rochester
Army Dlc 1 Cheat
Dcuo Exalted Style
Dimbleby Funeral Home
352-730-1982
Haslam Metrics
Is Slatt Offensive
Thermal Pants Mens Walmart
Genova Nail Spa Pearland Photos
Kay Hansen blowj*b
Integral2 seems to substitute non-scalar values of variable into in...
Uscis Fort Myers 3850 Colonial Blvd
Loterie Midi 30 Aujourd'hui
Altametrics Login Little Caesars
REGULAMENTUL CAMPANIEI "Extra Smart Week" valabil in perioada 12-18 septembrie 2024
2005 Chevy Colorado 3.5 Head Bolt Torque Specs
The University of Texas at Austin hiring Abatement Technician in Austin, TX | LinkedIn
Lufthansa LH456 (DLH456) from Frankfurt to Los Angeles
Hewn New Bedford
Dimbleby Funeral Home
Otter Bustr
Ridgid Pro Tool Storage System
Adult Theather Near Me
Raz-Plus Literacy Essentials for PreK-6
Sam's Club Near Me Gas Price
Mission Impossible 7 Showtimes Near Regal Bridgeport Village
Star Wars Galaxy Of Heroes Webstore
Whitfield County Jail Inmates P2C
Craigslist Ct Bridgeport
Apphomie.com Download
Directions To 401 East Chestnut Street Louisville Kentucky
Build:Mechanist - Power Mechanist
About My Father Showtimes Near Marcus Saukville Cinema
Math Nation Algebra 2 Practice Book Answer Key
Breckie Hill Shower Gif
Jimmy.johns Order Online
Latest Posts
Article information

Author: Frankie Dare

Last Updated:

Views: 6371

Rating: 4.2 / 5 (53 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Frankie Dare

Birthday: 2000-01-27

Address: Suite 313 45115 Caridad Freeway, Port Barabaraville, MS 66713

Phone: +3769542039359

Job: Sales Manager

Hobby: Baton twirling, Stand-up comedy, Leather crafting, Rugby, tabletop games, Jigsaw puzzles, Air sports

Introduction: My name is Frankie Dare, I am a funny, beautiful, proud, fair, pleasant, cheerful, enthusiastic person who loves writing and wants to share my knowledge and understanding with you.