adding new elements between each two elements of a vector

조회 수: 10 (최근 30일)
sarah Abdellahi
sarah Abdellahi 2019년 4월 8일
편집: Matt J 2019년 4월 8일
Experts,
I have a an array as follows:
T =
985 926 692 749
915 825 662 760
931 810 668 764
761 676 736 754
733 657 720 693
757 622 699 756
677 718 557 758
703 737 696 743
769 693 708 693
814 728 562 677
895 719 611 713
805 652 534 783
833 694 580 749
I want to linearly interpolate N points between each two elements of the array and add the new values in between. For example if N=3, T(1:5,1)= linspace(985, 915, 5), and same for the rest of the elements.
I would appreciate if someone can help me doing this, avoding for loop! maybe?
Thanks

채택된 답변

Matt J
Matt J 2019년 4월 8일
편집: Matt J 2019년 4월 8일
I can't tell if you mean to interpolate only between rows or between columns as well. If the former, then try this,
t=1:size(T,1);
q=linspace(t(1), t(end), (N+1)*(t(end)-1)+1);
Tnew=interp1(t,T,q);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by