Vector problem
조회 수: 4 (최근 30일)
이전 댓글 표시
I have a matrix
A =
Columns 1 through 5
1.5313 1.5316 1.5319 1.5321 1.5324
1.4612 1.4616 1.4619 1.4623 1.4627
1.4306 1.4308 1.4311 1.4314 1.4317
Columns 6 through 10
1.5327 1.5330 1.5333 1.5335 1.5338
1.4630 1.4634 1.4638 1.4641 1.4645
1.4319 1.4322 1.4325 1.4328 1.4331
Columns 11 through 15
1.5341 1.5344 1.5347 1.5349 1.5352
1.4649 1.4653 1.4656 1.4660 1.4664
1.4334 1.4337 1.4340 1.4343 1.4346
Columns 16 through 20
1.5355 1.5358 1.5361 1.5364 1.5367
1.4668 1.4672 1.4676 1.4680 1.4684
1.4349 1.4352 1.4355 1.4358 1.4361
Column 21
1.5369
1.4688
1.4364
I want to save all data that is A > 1.46 and A < 2.00, however when I use the command,
Index=and(neff_vec>2,neff_vec<1.46) neff_vec(Index)=0
it doesn't seem to do this.
However Index=and(neff_vec<2,neff_vec>1.46) does mark those that I want to save but neff_vec(Index) = 0 deletes those that I want to save.
Can anyone help me?
댓글 수: 0
채택된 답변
Fangjun Jiang
2011년 7월 23일
neff_vec(Index)=0 doesn't delete those elements. It assign value 0 to those elements. Use neff_vec(Index)=[] to delete those elements.
Use the removing approach, it should be.
Index=or(neff_vec>=2,neff_vec<=1.46);
neff_vec(Index)=[];
Use the saving approach, it should be.
Index=and(neff_vec<2,neff_vec>1.46);
neff_vec=neff_vec(Index);
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!