How can I plot 2 different matrix with different color at the same figure via scatter function?
1 回表示 (過去 30 日間)
古いコメントを表示
Hello,
Firstly, I'm new here and matlab. I've been trying to plotting 2 different matrix at the same figure. I have a 400*2 matrix; first column is expressing different matrix and second column is different matrix as well. Shortly,
dataset = xlsread('data.xlsx','Sheet1'); %loading data from excel table
plot(dataset(:,1),dataset(:,2), 'o-r', '*-g');
hold on
My goal is shortly showing the first matrix on the x- axis and showing second matrix on the y- axis at the same figure and each matrix will have unique color. Like a above figure. But I'm having an error. Can you help me please?
0 件のコメント
回答 (1 件)
dpb
2017 年 2 月 20 日
Well, to have something like the above figure you'd need two sets of x-y data, not just one list of two columns as you indicate. Oh, unless the two columns you're talking about above were to be cell array columns, but that doesn't jibe with xlsread that will return an "ordinary" array of doubles.
So, don't know where you're going to have the data sufficient to generate the plot shown.
But, given that you do have that, it's pretty simple albeit scatter doesn't handle arrays so you have to do it in two separate calls unlike plot
scatter(x1,y1,25,'r','*')
hold all
scatter(x1,y1,25,'b','+')
NB: the "trick" in ML HG to add stuff onto an axes after the first plot or line or whatever high-level function is to use hold on or hold all to keep the second call from clearing the previous data from the axes. See the documentation for more details and examples.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Discrete Data Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!