Ploting of two vectors with different lengths

5 ビュー (過去 30 日間)
Viswajit Talluru
Viswajit Talluru 2023 年 1 月 17 日
回答済み: KSSV 2023 年 1 月 17 日
I have two vectors xvalues(42471x1) and yvalues(29125x1). I need to plot these two values as their respective axis but unfortunately cant use NaN as the first value and last value in x and y are corrosponding to each other. I was asked to use spline function can some one help me out on this?
  1 件のコメント
Askic V
Askic V 2023 年 1 月 17 日
I suggest you to look interp1 function, or bet read this thread:
https://www.mathworks.com/matlabcentral/answers/488737-data-interp1-spline-and-cubic-method

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2023 年 1 月 17 日
Let x be of size 42471x1 and y be of size 29125x1.
nx = length(x) ;
ny = length(y) ;
% convert y to size of x
id = linspace(1,nx,ny)' ;
idi = linspace(1,nx,nx)' ;
yi = interp1(id,y,idi) ; % you can specify your method here
figure
hold on
plot(x,'r')
plot(yi,'.b')

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by