matlab - How to store variable length arrays? -


I want to store an array that changes its shape in every move of the loop. For example, y = 1: 100 for x = 1: 50 MS (:, X, Y) = ans; . . End end

'ans' is a line vector that changes its size in every move of y.

I have these variable lengths 'ans' to MS?

When I try to start 'MS' as a cell, then there is an error by saying that "it is not possible to repeat the conversion from cell."

How can I fix this?

Thanks regards

The only way I can actually think Using a cell array, start a 2D cell array like this:

  MS = Cell (50,100);   

After this, you create indexes in cells using curly braces ( {} ). Therefore, your loop will look like this: y = 1: 100 for x = 1: 50 MS {x, y} = ans; . . After you've finished, you can index the cell array by selecting the row and column location:

  Vec = ms {row, column};   

BTW, I do not recommend using ans as a variable ans is a default variable that you use In MATLAB execute a statement that has output and you will not specify the variable from the function where this output will not be specified. You may have code that will overwrite the ans variable, so you probably should use a different name.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -