Create a table from vectors with different rows and fill missing

2 次查看(过去 30 天)
I have a number of vectors for several dates with different lenghts
  • 01/06/2022: 478 rows
  • 02/06/2022: 531 rows
  • 03/06/2022: 502 rows
  • ...
I would like to add them to one array in order to plot them afterwards.
For this, they need to be the same rows.
I was thinking to create an array with set rows A = 0:500 and for example add the first 500 values.
The vectors with less would be filled with 'Nan' and the vectors with more would be cut short.
How could I do this in a loop?
  1 个评论
Mario Malic
Mario Malic 2022-9-1
Here's a minor example that you can expand yourself
a = ones(400, 1);
b = ones(450, 1);
c = ones(500, 1);
vecDim = max([numel(a), numel(b), numel(c)])
a(end + 1 : vecDim, :) = nan;

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by