Tuesday, November 22, 2011

How can I store a number in a vector in matlab?

I have to write a function in matlab.


it will prompt the user for a number, and then store the number in a vector and ask for another number until a negative number is given, then the function will stop and return the vector of positive numbers previously stored.


Thanks so much!|||The command that you want to use in your function will be "INPUT".





You would use it something like this:





a = input("Enter a value: ")





The variable "a" will hold the numeric value and then you can test to see if it is less than zero. If not, then you can assign the value of "a" to the next index in your vector.

No comments:

Post a Comment