set the vector same length

12 ビュー (過去 30 日間)
chris patel
chris patel 2021 年 2 月 21 日
回答済み: Star Strider 2021 年 2 月 21 日
I have two sets of data, stress and strain. this a project and i have only 5 values in y and 9 values in x axis.
x values (2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016)
and y value (0, 0.05, 0.1, 0.15, 0.2)
I need both vectors to be the same length, which would be [9 X1]. I am not sure what to do . can anyone plese help me? thank you in advance

回答 (1 件)

Star Strider
Star Strider 2021 年 2 月 21 日
The approach depends on what you want as the result:
x = [2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016];
y = [0, 0.05, 0.1, 0.15, 0.2];
y9 = linspace(min(y), max(y), numel(x)); % Option #1
y9 = interp1(x(1:numel(y)), y, x, 'linear', 'extrap'); % Option #2
Try these and see if either of them does what you want.

カテゴリ

Help Center および File ExchangeStress and Strain についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by