Clear Filters
Clear Filters

use of horzcat

1 view (last 30 days)
Richard
Richard on 19 Jun 2012
What is the use of horzcat? Is there an advantage of using horzcat over manually concatenating arrays horizontally? for example:
A = {'a','b','c'};
B = {'d','e'};
C = horzcat(A,B);
This is the same as:
A = {'a','b','c'};
B = {'d','e'};
C = [A,B];
So, is there an advatage of using horzcat?

Accepted Answer

Jan
Jan on 20 Jun 2012
When you type [A, B] in the code, horzcat is called internally, as it is when it is called explicitely also. [.,.] is a synonym only.
cat(2, A, B) replies the same result, but as far as I remember it has a tiny difference in the runtime.
  1 Comment
rudolf
rudolf on 10 Jul 2012
Hello Jan
If i have several txt files on a folder instead of specify A, B, C,... how can i read all files inside a folder Im trying to use:
C=cat(1, F{:}) but is not working
Thanks rf

Sign in to comment.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!