why legend for multiple matrix is not showing the appropriate data?

I have 6 matrix as A=rand(10,10),B=rand(10,10),C=rand(10,10) and a=rand(10,10),b=rand(10,10),c=rand(10,10). i want to plot all elements as plot(a,A,'r*',b,B,'b+',c,C,'go'); i am able to plot this way but while calling legend i am facing problem.
i want legend('a','b','c'); where a will indicate red color *,b as blue + and c as green o.
can it be done please help me...i am getting output as

3 Comments

Suchismita, I do not see anything wrong with your code. What exactly is not working as expected?
all elements are not getting plotted....i dont want lines...i want all element to be in a figure...
i have changed my question please have a look....

Sign in to comment.

 Accepted Answer

When I run your code I get this:
Could you be more precise as to what exactly you want?

6 Comments

ya just now i got too before it was not coming...it was coming in a line only thank u....so much....
while writing legend for it why only one color it is accepting whereas it should indicate all colors one by one correct????
given the way your data are entered, you would need this line after the plot command:
legend('a','A','b','B','c','C');
Which gives this:
but i want in some other way.. i have changed my question please recheck...
can i get result that way....???????
please let me know asap....
i have done it!!!!
hold on
p1=plot(a,A,'or');
p2=plot(b,B,'+b');
p3=plot(c,C,'pg');
legend([p1(1) p2(1) p3(1)], 'a','b','c');
this worked.....

Sign in to comment.

More Answers (0)

Tags

Asked:

on 24 Jun 2014

Commented:

on 25 Jun 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!