answersLogoWhite

0


Best Answer

First, make sure your vector is initialized outside of the loop. Then, within your loop you need to update the vector. If you want data entered by the user only, you should initialize with an empty vector.

Example program (not sure which loop you're using, but I'll use a while loop here):

vector=[];

user='y';

while user=='y'

user=input('Enter another variable? Type y for yes and n for no: ');

if user=='n'

break

end

var=input('Please input variable: ');

vector=[vector, var];

end

The key part in this coding is the line:

>> vector=[vector,var];

as this will update your vector with the previous vector values, and then add another value to the vector with whatever number var is.

Hope this helps!

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How would I add numbers input by a user one at a time into a vector in MATLAB I have the loop set up but don't know how to add the data into the vector?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you modulate in matlab without using matlab tools?

You would have to write your own code for a modulation (Matlab has a convolution function not in the tools), otherwise you can use its built in function in the signal processing toolbox.


Which of these references a velocity (not speed)?

I would say vector


What universities use MATLAB?

I would hope most have an institution license.


A force has a magnitude of 10 newtons what other information is needed to have a complete description of its properties as a force?

No other information is needed if the force is a scalar force. Only if one believes that force is only a vector then one would need the direction information. However, it is a wrong to believe that force is only a vector. Force in general is a quaternion. A quaternion can be a scalar or a vector, thus a force can be a scalar or a vector or both. But it is cleaner to think of scalar forces as being in a single direction. Thus the direction of force is implicit, not that it does not matter. A.k.a. a scalar force is a force with an implicit direction while a vector force is a force with an explicit direction. It is cleaner to consider a scalar force as having a direction angle of a multiple of 180 degrees and a vector force having a direction angle a multiple of 90 degrees. Any other angle would be give a scalar and vector, or a quaternion. This is similar to complex numbers, there are real numbers, imaginary numbers and complex numbers. Reals and complex numbers are subsets of quaternions.


Could this ever be the rule of a function For input x the output is the number whose square is x If so what is its domain and range?

Yes, the domain(input) would be all natural numbers (numbers greater or equal to zero). The range (output) would be all real numbers. -- Not only natural numbers would be considered part of this domain, all negative numbers are also reasonable inputs to this function, as any negative number multiplied by itself would produce a positive number..... The output (range) would therefore be all positive real numbers......


What is the column vector?

In mathematics a vector is just a one-dimensional series of numbers. If the vector is written horizontally then it is a row vector; if it's written vertically then it's a column vector.Whether a vector is a row or a column becomes significant usually only if it is to figure in multiplication involving a matrix. A matrix of m rows with n columns, M, can multiply a column vector, c, of m rows, on the left but not on the right.That is, one can perform Mv but not vM. The opposite would be true for a row vector, v, with 1 row and m columns.


Why a unit vector is aone type of vector but a vector is not a unit vector?

A unit vector is a vector whose magnitude is one. Vectors can have magnitudes that are bigger or smaller than one so they would not be unit vectors.


When should you express a vector along the x-axis as a negative vector?

You express a vector along the X-axis as a negative vector when the arrow representing the vector would point toward negative x.


What is the best matlab version for an engineer?

You could get a free license version of MATLAB such as Octave or FreeMat. You can find it very easily by a WWW search. Personally I do use MATLAB from the Mathworks, although you would have to purchase it from the Mathworks. Octave and FreeMat are essentially the same as MATLAB, except a few differences in syntax. If you are a student, you could purchase it at a low cost from the Mathworks. It is slick and simple to get into, and I think worth the cost.


Is direction a vector?

"North" is a valid direction, but for a vector, you would also need a magnitude.


Is mosquito a vector?

I would say yes, as it can carries Malaria.


What are the Examples of a vector quantity?

Some examples of a vector quantity would be a car or a plane.