Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Matlab - Stack Data Structure

Tags:

matlab

Can I have a stack data structure in matlab?

For example a stack of integers where I can push elements in it like stack.push(i), get elements out of it like i = stack.pop() and check out if it is empty stack.isempty().

like image 270
Simon Avatar asked Nov 12 '10 10:11

Simon


People also ask

What is Matlab stack?

The stack function interleaves values from the specified variables in U to create one variable in S . For example, if U has 10 rows and you stack three of the variables from U , then S has 30 rows. In general, S contains fewer variables, but more rows, than U .

How to implement stack in MATLAB?

Just write in MATLAB stack=java. util. Stack() and then you can call methods on it as in your question stack.


1 Answers

I do not think MATLAB has one even in the newer versions. But you can use Java, it is a "first class citizen" in MATLAB, it would work perfectly with integers as you need it. See also queue and linked-list related questions.

Just write in MATLAB stack=java.util.Stack() and then you can call methods on it as in your question stack.push(i), ecc.

like image 159
Mikhail Poda Avatar answered Oct 02 '22 11:10

Mikhail Poda