Adding a column in particular location

HI,
I have a metrics and I want to add a column with Title and values. I can create that column and do horzcat but that can add a column first or last. I want to add as a 3rd column. How do i do it?

 Accepted Answer

[A(:,1:2), B(:), A(:,3:end)]

3 Comments

ok thanks! is this the only option? Is there anyway to refer them by col title and rearrange the columns?
Possibly if you use a "table" you could do that.
Otherwise, you could use ismember() of each column title you wish to refer to, comparing to the cell array of strings of column titles. With the two-output version if ismember() that would give you the numeric column indices that you could then re-arrange.
Ok, great, thanks

Sign in to comment.

More Answers (0)

Products

Asked:

on 16 Dec 2013

Commented:

on 16 Dec 2013

Community Treasure Hunt

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

Start Hunting!