finding elements in array
이전 댓글 표시
I have an array
vk = [0 0.025 0.05 0.075 0.1 0.125 0.15 0.175].
I am writing this line
op= vk(vk>= 0.05 & vk<= 0.175)
The result which I am getting is
op =
0.0750 0.1000 0.1250 0.1500 0.1750
which is wrong, I should get
0.05 0.0750 0.1000 0.1250 0.1500 0.1750
does anyone know what I am doing wrong?
Also how I can get the indices number of the array vk and of op?
댓글 수: 6
Meg Noah
2020년 1월 10일
It worked for me:
vk = [0 0.025 0.05 0.075 0.1 0.125 0.15 0.175];
op = vk(vk>= 0.05 & vk<= 0.175)
>> vk = [0 0.025 0.05 0.075 0.1 0.125 0.15 0.175];
op= vk(vk>= 0.05 & vk<= 0.175)
op =
Columns 1 through 4
0.05 0.075 0.1 0.125
Columns 5 through 6
0.15 0.175
Chris Dan
2020년 1월 11일
Chris Dan
2020년 1월 11일
Possibly you have issues with floating point error. Print the exact number values:
and you might find that the values are not what you think they are. See also:
This is worth reading as well:
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

