Using rows of matrix as elements in a new matrix.

1 回表示 (過去 30 日間)
Aditya Jain
Aditya Jain 2019 年 10 月 8 日
回答済み: Star Strider 2019 年 10 月 8 日
I have a 2x12 matrix of X and Y cordinates, how do I make a new 2xn matrix of pairs of these points?

回答 (1 件)

Star Strider
Star Strider 2019 年 10 月 8 日
Try this:
M = [1:12; rand(1,12)]; % Original Matrix
n = 50;
xnew = linspace(min(M(1,:)), max(M(1,:)), n); % Create 50-Point Interpolation Vector
ynew = interp1(M(1,:), M(2,:), xnew, 'pchip'); % Choose The 'pchip' Method To Illustrate The Interpolation, Use Whatever You Want
figure
plot(M(1,:), M(2,:), 'xr')
hold on
plot(xnew, ynew, '--b')
hold off
grid
Choose ‘n’ to be anything you want, and use whatever interpolation method you want. See the documentation on interp1 for the available options.

カテゴリ

Help Center および File ExchangeInterpolation of 2-D Selections in 3-D Grids についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by