Clear Filters
Clear Filters

adding new elements between each two elements of a vector

9 views (last 30 days)
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

Accepted Answer

Matt J
Matt J on 8 Apr 2019
Edited: Matt J on 8 Apr 2019
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);

More Answers (0)

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!