1
votes

I have a figure(not using the plot command) in which the xdata is stored as an array of cells(as opposed to a matrix). What I want to do is shift the plot horizontally, which could be done by adding a constant value to each element of xdata or shift the x-axis without affecting the plot.

I am not able to do so, and would really appreciate any help. Btw, my knowledge of MATLAB is very limited.

This is what I tried, and I seem to be getting an error: set(findobj('type', 'line', 'color', 'r',),'xdata', new)

where 'new' is another cell array of the same dimensions as 'xdata'. But I don't see why this results in the error: "conversion to double fromcell is not possible"

1
can you show which commands did you use? - Yasir Malik
I am supposed to design a QFT controller, for which I downloaded a user-made QFT toolbox. This, contained a predefined function 'plotbnds', which is similar to 'plot', but has the xdata, ydata stored as a cell array. I really don't know much about what the function does - user1471216

1 Answers

0
votes

First of all, the reason why get(findobj('type', 'line', 'color', 'r',),'xdata') returns a cell array is that there are multiple red-colored lines in your figure. If you clicked on the white arrow icon in the figure menu, selected one of the lines, and called get(gco,'xdata'), you'd see that the xdata-property of each individual line is still the normal numeric array.

In order to set the properties for a list of graphical objects, you need to put xdata into curly brackets (see the documentation of the set command):

 horizontalShift = 100;
 old = get(findobj('type', 'line', 'color', 'r',),'xdata');
 new = cellfun(@(x)x+horizontalShift,old,'UniformOutput',false);

 set(findobj('type', 'line', 'color', 'r',),{'xdata'}, new)