Ask your own question, for FREE!
Mathematics 9 Online
OpenStudy (raffle_snaffle):

matlab question

OpenStudy (raffle_snaffle):

%% 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);

OpenStudy (raffle_snaffle):

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.

OpenStudy (raffle_snaffle):

@jim_thompson5910

jimthompson5910 (jim_thompson5910):

So you just want the textbox to say `\leftarrow sin(pi) = 0` ?

jimthompson5910 (jim_thompson5910):

how exactly do you want this text box to look? I'm assuming you want it on your graph somehow?

OpenStudy (raffle_snaffle):

I actually got it figured out

jimthompson5910 (jim_thompson5910):

ok great

OpenStudy (raffle_snaffle):

but I am a little confused still.

OpenStudy (raffle_snaffle):

% txt box for y1 y1 = sin(x); x1 = pi; txt1 = '\leftarrow sin(\pi) = 0'; text(pi/12, 0, txt1);

jimthompson5910 (jim_thompson5910):

what's not making sense?

OpenStudy (raffle_snaffle):

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

OpenStudy (raffle_snaffle):

so what is pi/12 doing is this the x-axis per say?

jimthompson5910 (jim_thompson5910):

|dw:1461630328718:dw|

jimthompson5910 (jim_thompson5910):

|dw:1461630335365:dw|

jimthompson5910 (jim_thompson5910):

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

OpenStudy (raffle_snaffle):

no it doesn't say specific. I took that example from mathworks site

OpenStudy (raffle_snaffle):

we can place them wherever we want.

jimthompson5910 (jim_thompson5910):

`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

jimthompson5910 (jim_thompson5910):

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)

OpenStudy (raffle_snaffle):

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

jimthompson5910 (jim_thompson5910):

no problem

OpenStudy (raffle_snaffle):

@jim_thompson5910

OpenStudy (raffle_snaffle):

is there anyway to just show that graph 1 is y1 = sin(x) , y2 = sin(2x), and y3 = sin(3x) ?

jimthompson5910 (jim_thompson5910):

you mean plot them all on the same coordinate grid?

OpenStudy (raffle_snaffle):

nvm it works now

OpenStudy (raffle_snaffle):

it wasn't working before.

OpenStudy (raffle_snaffle):

|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

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!