Plotting doubles against cells
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Joel Schelander
le 28 Avr 2021
Modifié(e) : Turlough Hughes
le 28 Avr 2021
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 .
4 commentaires
Turlough Hughes
le 28 Avr 2021
Ok that helps, my follow up question is how does the data in AAG{3,1} relate to AAI{3,1}, are you expecting 923 horizontal lines for AAG{3,1} and AAI{3,1}? Do you want to plot it all on the same chart?
Réponse acceptée
Turlough Hughes
le 28 Avr 2021
Modifié(e) : Turlough Hughes
le 28 Avr 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);
end
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:
ii=3;
figure(), hold on,
arrayfun(@(idx) plot(X{ii}{idx},repmat(Y{ii}(idx),[1 numel(X{ii}{idx})]),'.') ,1:numel(Y{ii}))
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Create Fixed-Point Objects in MATLAB dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!