matlab question
%% 5.5 % Adjust the plot created in Problem 5.4 so that the x-axis goes from -6 % to +6. % Add a legend % Add a text box describing the plots. x = -6:0.05:6; % new x-axis from -6 to +6 % sin functions y1, y2, and y3 y1 = sin(x); y2 = sin(2*x); y3 = sin(3*x); % sins plotted (Lines 1-3) plot(x, y1, 'r--', x, y2, 'b', x, y3, 'g:'); legend('y1', 'y2', 'y3'); % txt box for y1 y1 = sin(pi); x1 = pi; txt1 = '\leftarrow sin(pi) = 0'; text(x, y1, txt1);
How do I code the textbox? I was looking at mathworks site and found an example, however it displays many equation along the sine wave which isn't what I want.
@jim_thompson5910
So you just want the textbox to say `\leftarrow sin(pi) = 0` ?
how exactly do you want this text box to look? I'm assuming you want it on your graph somehow?
I actually got it figured out
ok great
but I am a little confused still.
% txt box for y1 y1 = sin(x); x1 = pi; txt1 = '\leftarrow sin(\pi) = 0'; text(pi/12, 0, txt1);
what's not making sense?
text(pi/12, 0 txt1) as I increase the 12 the arrow shift to the left. I used pi at first and the arrow was located at the end of the graph on the right side at y = 0
so what is pi/12 doing is this the x-axis per say?
|dw:1461630328718:dw|
|dw:1461630335365:dw|
so in this case, the textbox is placed at (pi/12, 0). That part I'm sure of. The part I'm not sure of is where the reference point on the texbox is. Is it in the left upper corner? center? I don't know
no it doesn't say specific. I took that example from mathworks site
we can place them wherever we want.
`as I increase the 12 the arrow shift to the left` so what you're doing is making the x coordinate (of where you're placing the textbox) smaller. Which means it shifts more towards 0. So more to the left on the x axis number line
I'm sure you've probably seen this example already http://www.mathworks.com/help/examples/graphics/LabelPointOnGraphExample_01.png the code for it is text(pi,0,'\leftarrow sin(\pi)') so this textbox is placed at (pi,0)
I was looking at that now. I will play around with this some more. I think I understand and can apply text box to the other two graphs now. Thanks
no problem
@jim_thompson5910
is there anyway to just show that graph 1 is y1 = sin(x) , y2 = sin(2x), and y3 = sin(3x) ?
you mean plot them all on the same coordinate grid?
nvm it works now
it wasn't working before.
|dw:1461632889651:dw| This is what I wanted the text to say and it works now. At first the arrow was there it just displayed leftarrow
Join our real-time social learning platform and learn together with your friends!