simple for cycle!
Show older comments
I have one vector:
massa=massa =
-0.2000
-0.1932
-0.1729
-0.1397
-0.0946
-0.0386
0.0265
0.0992
0.1773
0.2587
0.3413
0.4227
0.5008
0.5735
0.6386
0.6946
0.7397
0.7729
0.7932
0.8000
I run this cycle to have to have two separate vectors (one for negative valuse and one for positive values), one for the negative massa, and one for the positive:
for i=1:length(massa)
if massa(i) < 0
massa_neg(i) = massa(i);
else
massa_pos(i) = massa(i);
end
end
I get the right for the massa_neg but for massa_pos it puts zeros instead of nothing:
0 0 0 0 0 0 0,0265259209387866 0,0991522876735153 0,177257256429600 0,258710327263834 0,341289672736166 0,422742743570400 0,500847712326485 0,573474079061213 0,638640785812871 0,694570254698197 0,739736875603245 0,772908620850317 0,793180651701361 0,800000000000000
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!