HP Forums

Full Version: Apply a function to a vector
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to apply an arbitrary function to a predefined vector in HOME environment or in a program for some numerical analysis, similar to Matlab.
For example in Matlab I define a vector of discrete time values and apply a function to this vector simply by two commands:

t = (0:0.001:1); ➝ time vector from 0 to 1 sec with 1001 samples
y = sin(t); ➝ y is a vector with 1001 sampled sin(t) - values

Is that also possible with the prime in Home or in programs? I think the CAS functions "apply" or "map" can do this job, but I would like to avoid using CAS functions for the numerical analyses I'm working on.

Thanks for any input!
Perhaps, something like this?



y:=SIN(MAKELIST(X,X,0,1,0.001)); // y:=sin(X)


M1:=SIN(t); // Uses reserved variable M1 to save in matrix (vector) form.

Great! Thanks a lot, Dale. That works doing it with MAKELIST.
I didn't think about lists and only noticed that functions like SIN don't accept vectors as arguments. When using a list as argument it works fine.

Thanks again

Mathlab does not have a distinction between lists and vectors/matrices.

Prime does as they are different mathematical objects and behave differently with regard to some mathematical operations. Therefore the difference.

Reference URL's