last number is out of matrix range range
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi guys,
I need your help with this problem please, n1=492;n2=354;% first and last elements of x X=n1:(n2-n1)/(length(x)*1.25):n2; where x=[492 486 483 476 474 474 472 468 466 460 456 456 454 452 444 440 438 432 428 424 420 418 414 411 408 400 388 374 354];
the problem is that the last element of X(X(end)=3.549517241379310e+002) will be a little bit greater than n2= 354 ( the last element of x) is there any way to fix this problem to get (X(end)=n2=x(end))
댓글 수: 0
답변 (3개)
Image Analyst
2013년 9월 23일
Can't you just use linspace???
outputArray = linspace(startingValue, endingValue, numberOfElements);
댓글 수: 0
David Sanchez
2013년 9월 23일
you can round the last element:
n1=492; n2=354; x = ones(20,1); X=n1:(n2-n1)/(length(x)*1.25):n2;
X2 = floor(X);
X2 =
Columns 1 through 9
492 486 480 475 469 464 458 453 447
Columns 10 through 18
442 436 431 425 420 414 409 403 398
Columns 19 through 26
392 387 381 376 370 365 359 354
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!