To create a column in front of a matrix?

Asked 1 years ago, Updated 1 years ago, 59 views

a=[2016;2016;2016;2016;2016;];  (5x1 double)
b=[06;06;06;06;06;];   (5x1 double)

From

c= ([a,b]);  (5x2 double)

When you run the .

But c(:, (-2,-1))= nan; If you do , 'The index at position 2 is not valid. Array indexes must be positive integers or logical values.' That's what it says. What I'm curious about is that I want to add a new column to the front of the first row, for example Like this

Isn't there a function or expression that we insert into the front of the first row? Do I have to create a new matrix 5x4 matrix and hang it out?

matlab

2022-09-20 20:19

1 Answers

Please refer to the code below.

a=2016*ones(5,1);
b=6*ones(5,1);
c=[a b];

c=[nan*ones(5,2) c];


2022-09-20 20:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.