The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Using horzcat or cat - Easy
Replies: 1   Last Post: Mar 6, 2013 6:26 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Kevin Ellis

Posts: 62
Registered: 11/29/10
Using horzcat or cat - Easy
Posted: Mar 6, 2013 5:49 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


I have an easy problem. My program outputs the following into separate variables, but can be created using these commands (not the issue):

A = [{'Diesel'};{'Gasoline'}];
B = [2;3];

Could someone explain why you cannot horizontally concatenate these two arrays? If I try cat(2,A,B) I get the following:

Error using cat
Dimensions of matrices being concatenated are not consistent.

I get the same using horzcat(A,B). All I want is a matrix that looks like:

C =

'Diesel' 2
'Gasoline' 3

But for some reason I cannot figure out how to do something this simple in MatLab. Any help would be much appreciated.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.