Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link
URL Rewriter Bot
URL Rewriter Bot

This is a follow-up question to How to append an element to an array in MATLAB?How to append an element to an array in MATLAB? That question addressed how to append an element to an array. Two approaches are discussed there:

A = [A elem] % for a row array A = [A; elem] % for a column array 

and

A(end+1) = elem; 

The second approach has the obvious advantage of being compatible with both row and column arrays.

However, this question is: which of the two approaches is fastest? My intuition tells me that the second one is, but I'd like some evidence for or against that. Any idea?

This is a follow-up question to How to append an element to an array in MATLAB? That question addressed how to append an element to an array. Two approaches are discussed there:

A = [A elem] % for a row array A = [A; elem] % for a column array 

and

A(end+1) = elem; 

The second approach has the obvious advantage of being compatible with both row and column arrays.

However, this question is: which of the two approaches is fastest? My intuition tells me that the second one is, but I'd like some evidence for or against that. Any idea?

This is a follow-up question to How to append an element to an array in MATLAB? That question addressed how to append an element to an array. Two approaches are discussed there:

A = [A elem] % for a row array A = [A; elem] % for a column array 

and

A(end+1) = elem; 

The second approach has the obvious advantage of being compatible with both row and column arrays.

However, this question is: which of the two approaches is fastest? My intuition tells me that the second one is, but I'd like some evidence for or against that. Any idea?

added 11 characters in body
Source Link
jub0bs
  • 67.3k
  • 27
  • 198
  • 200

This is a follow-up question to How to append an element to an array in MATLAB? That question addressed how to append an element to an array. Two approaches are discussed there:

A = [A elem] % for a row array A = [A; elem] % for a column array 

and

A(end+1) = elem; 

The second approach has the obvious advantage of being compatible with both row and column arrays.

However, this question is: which of the two approaches is fastest? My intuition tells me that the second one is, but I'd like some evidence for or against that. Any idea?

This is a follow-up question to How to append an element to an array in MATLAB? That question addressed how to append an element to an array. Two approaches are discussed there:

A = [A elem] % for a row array A = [A; elem] % for a column array 

and

A(end+1) = elem; 

The second approach has the obvious advantage of being compatible with both row and column arrays.

However, this question is: which of the two approaches is fastest? My intuition tells me that the second one is, but I'd like some evidence for that. Any idea?

This is a follow-up question to How to append an element to an array in MATLAB? That question addressed how to append an element to an array. Two approaches are discussed there:

A = [A elem] % for a row array A = [A; elem] % for a column array 

and

A(end+1) = elem; 

The second approach has the obvious advantage of being compatible with both row and column arrays.

However, this question is: which of the two approaches is fastest? My intuition tells me that the second one is, but I'd like some evidence for or against that. Any idea?

Source Link
jub0bs
  • 67.3k
  • 27
  • 198
  • 200

What is the fastest way of appending an element to an array?

This is a follow-up question to How to append an element to an array in MATLAB? That question addressed how to append an element to an array. Two approaches are discussed there:

A = [A elem] % for a row array A = [A; elem] % for a column array 

and

A(end+1) = elem; 

The second approach has the obvious advantage of being compatible with both row and column arrays.

However, this question is: which of the two approaches is fastest? My intuition tells me that the second one is, but I'd like some evidence for that. Any idea?