MATLAB Answers

Plotting doubles against cells

1 view (last 30 days)
I have 36 cells in the cell array AAG(36x1) A cell looks like this:
AAG{3,1}=1x923 cell={1x757 double 1x726 double 1x761 double 1x785 double 1x773 double 1x788 double...}
For each double, I have one value in another cell array AAI(36x1)
AAI{3,1}=1x923 double=[8 11 8 11 8..7...]
What I want is to plot AAI against AAG.
I have tried using 2 functions and for loops to make to column vectors with all values in AAG plotted against the values in AAI repeated .
Joel Schelander
Joel Schelander on 28 Apr 2021
Yes, all on the same chart.,
So for example the first value 8 in AAI{3,1} should be plotted against the first cell in AAG{3,1} (1x757 double)

Sign in to comment.

Accepted Answer

Turlough Hughes
Turlough Hughes on 28 Apr 2021
Edited: Turlough Hughes on 28 Apr 2021
Here's an example, i've used X and Y in place of AAG and AAI to simplify:
% example data
X = arrayfun(@(x) cell(1,randi(1000,1)),1:36,'uni',false).'; % for AAG
Y = arrayfun(@(x) rand(1,numel(X{x})),1:36,'uni',false).'; % for AAI
for ii = 1:numel(X)
X{ii} = cellfun(@(x) randi(1000,[1 randi(100)]),X{ii},'uni',false);
So X is a 36 by 1 column of cells, where each cell contains a row of cell, each of which contains several row vectors of numeric data. Each of the numeric row vectors comprise the x data that you want to plot at a single height, y for that row of data. For each row of cells contained in the 36 cells in X, there is a corresponding numeric row vector contained in the cells of Y with equal size indicating the heights for each line.
To plot results for X{3,1} you could do the following:
figure(), hold on,
arrayfun(@(idx) plot(X{ii}{idx},repmat(Y{ii}(idx),[1 numel(X{ii}{idx})]),'.') ,1:numel(Y{ii}))

More Answers (0)




Community Treasure Hunt


Start Hunting!