I want to draw my plot like the one shown in the attachment. I tried but in vain.

 Réponse acceptée

the cyclist
the cyclist le 1 Juil 2022

0 votes

There are examples in the documentation for the plot command that are very similar to this, for example:
x = 0:pi/10:2*pi;
y1 = sin(x);
y2 = sin(x-0.25);
y3 = sin(x-0.5);
figure
plot(x,y1,'g',x,y2,'b--o',x,y3,'c*')
You'll also need the legend command.

7 commentaires

Sadiq Akbar
Sadiq Akbar le 1 Juil 2022
Thank you very much dear the cyclist. But how will we put triangles and circles instead of above i.e., staric etc.?
the cyclist
the cyclist le 1 Juil 2022
The LineSpec property specifies what the line and markers will look like. You can see in the example I posted that the first line is solid green (with no marker), for example.
Please read through the documentation link I put in my prior post (and the link I just posted, which is a section of that page). You will learn how to do this, rather than needing someone else to do it for you.
Sadiq Akbar
Sadiq Akbar le 4 Juil 2022
Thank you very much dear the cyclist. Yes you are right. But if you see the symbols on are on the graph lines in the attached figure. But when I plot yours, some symbols come on plot lines and some of them come above and below the graph lines. Why it is so?
the cyclist
the cyclist le 4 Juil 2022
Modifié(e) : the cyclist le 4 Juil 2022
I'm not sure I understand what you mean. In the example I posted, from the documentation, three different y values are plotted (y1, y2, y3), with three different styles:
  • y1: green, solid line, no marker -- 'g'
  • y2: blue, dashed line, circle marker -- 'b--o'
  • y3: cyan, no line, asterisk marker -- 'c*'
Nothing is plotted above or below its own line.
You seem to have a very similar situation, which is why I chose that example to post. For example, your "Proposed method" line has no marker, which makes it similar to y1 in my example.
Sadiq Akbar
Sadiq Akbar le 4 Juil 2022
Thank you very much for your prompt response. If you see the attached figure, all the plot lines are solid in it, but when I run your code, it gives me only one solid line of green colour and having no markers. The 2nd line is a dashed line with circles on it and is of blue colour. But the 3rd line is neither solid nor dashed i.e., its not visible but only cyan colour stars are there. But in given attached figure, all lines are visible.
the cyclist
the cyclist le 4 Juil 2022
My example is not intended to create your exact figure.
My example is intended to teach you how the MATLAB syntax works. It should be very easy for you to read the documentation I posted, and edit my example to do what you need. For example, to create a triangle marker instead of a circle marker, you can use '-^' instead of '-o'.
Sadiq Akbar
Sadiq Akbar le 4 Juil 2022
Ok dear the cycllist thank you very much for your help.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

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

Start Hunting!

Translated by