简体   繁体   中英

How to plot each column of a cell array?

I have a cell array that looks like this:

Column1           Column2
[1 2 3 4]         [2 5 6 9]
[1 3 4]           [3 4 7 8]
[2 3 4]           [1 3 7 9]
[1 2 4]           [1 4 6 8]

There are a few more columns that have similar styles of data. I need to create a way to make a graph of each column (separate graphs for each column of the array), that plots each point as a number from each double as the x-coordinate, and the row as the y-coordinate. It should look something like this:

(Row)
1 x  x  x  x
2 x     x  x
3    x  x  x
4 x  x     x
  1  2  3  4 
X is just a point on the graph.

Does this make enough sense? I feel like I'm making 0 progress in explaining what I want. If anyone doesn't understand this, feel free to ask questions and I'll answer them as best I can.

Something like this?

cin = { {[1 2 3 4] , [1 3 4], [2 3 4], [1 2 4]}, {[1 2 3 8] , [1 3 4], [2 3 4], [1 2 4]} };

for k=1:numel(cin)
    col_k = cin{k};

    figure();  %// 1 figure per column
    for y=1:numel(col_k)
        plot(col_k{y}, y);
        hold on;
    end    
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM