`%this program creates vectors N and P out of x`

%N will contain negative elements and P the positive elements

x=[-3.5 -5 6.2 11 0 8.1 -9 0 3 -1 3 2.5];for k=length(x); if x>=0 k=x P(k)=k else x<0 N(k)=k endendPN

# MATLAB: I am trying to create two vectors out of one,x, where one will contain all the positive elements and the other all the negative elements.

loopsvector

###### Related Question

- How to use a for loop to return a vector
- Difficulty finding euclidean distance to match
- Below is the probabilistic neural network for classification, but it is not working fine. Can someone help to improve it? especially how to recalculate training, validation and test performance.
- How to extract a distribution from a 2d histogram
- DATA ANALYSIS
- Scatter3, Meshgrid coordinate misalignment. How to fix this
- I have a matrix A of order 3 X 7 and C is a matrix made

## Best Answer