Displaying a value on a plot

  • Follow


I want to display a value on the plot...my code is as follows..

plot(a,b);
hold on
plot(a,c);
axis([400 850 0 1]);
legend('first','second');
text(465,0.9,'Value=N(i)');

I want to display the value stored in N(i) on the plot.When i used this code it displaying just that string. Instead i want to display the value stored.Thanks in advance!
0
Reply lramsb4u (16) 6/18/2010 1:48:46 PM

On Jun 18, 11:48=A0am, rams <lrams...@gmail.com> wrote:
> I want to display a value on the plot...my code is as follows..
>
> plot(a,b);
> hold on
> plot(a,c);
> axis([400 850 0 1]);
> legend('first','second');
> text(465,0.9,'Value=3DN(i)');
>
> I want to display the value stored in N(i) on the plot.When i used this c=
ode it displaying just that string. Instead i want to display the value sto=
red.Thanks in advance!

When specify N(i) in a string, it doesn't know that you're actually
trying to access a variable.  Try something like:

text(465, 0.9, sprintf('Value=3D%d', N(i)))
0
Reply jrenfree 6/18/2010 6:53:37 PM


rams wrote:
> I want to display a value on the plot...my code is as follows..
> 
> plot(a,b);
> hold on
> plot(a,c);
> axis([400 850 0 1]);
> legend('first','second');
> text(465,0.9,'Value=N(i)');
> 
> I want to display the value stored in N(i) on the plot.When i used this code it displaying just that string. Instead i want to display the value stored.Thanks in advance!

text(465,0.9,sprintf('Value=%f',N(i)));
0
Reply Walter 6/18/2010 6:55:37 PM

rams <lramsb4u@gmail.com> wrote in message <398797414.369466.1276886957011.JavaMail.root@gallium.mathforum.org>...
> I want to display a value on the plot...my code is as follows..
> 
> plot(a,b);
> hold on
> plot(a,c);
> axis([400 850 0 1]);
> legend('first','second');
> text(465,0.9,'Value=N(i)');
> 
> I want to display the value stored in N(i) on the plot.When i used this code it displaying just that string. Instead i want to display the value stored.Thanks in advance!


.... or, if you'd like to do it the Matlab way:

text(465,0.9,['Value=' num2str(N(i)) ]);
0
Reply Wes 6/18/2010 7:49:04 PM

3 Replies
166 Views

(page loaded in 0.036 seconds)


Reply: