MATLAB Answers

How to make a reference to multiple subelements of a cell without for loop (to create a plot)

3 views (last 30 days)
Felix
Felix on 6 Nov 2012
lets say I have a axb cell , each cell contains a 1xn double I want to make a plot like this plot({1,:}(1,end)) , i.e. for the first row of this cell I want to plot each cells last datapoint. I know this syntax doesn't work for cells, and it gives me the error "Incorrect cell or structure reference involving "end". Most likely cause is a reference to multiple elements of a cell or structure followed by additional subscript or structure references."
But how would you do this seemingly simple task?

  0 Comments

Sign in to comment.

More Answers (1)

Harshit
Harshit on 6 Nov 2012
Hi Felix, You have to use cell2mat. It converts your code to matrix. You have knowledge about n so pick up every nth element. It can be done easily.

  1 Comment

Felix
Felix on 6 Nov 2012
Unfortunately the size of n is different in every cell, thats why I wanted to use "end". Therefore cell2mat gives an error because the whole cell does not form a rectangle.

Sign in to comment.

Sign in to answer this question.


Translated by