Problem in plotting a specific function graph

3 messages
Open this post in threaded view
|

Problem in plotting a specific function graph

I am new user of Octave. I wanted to plot a function and I wrote this code:
pi=3.14159;
t=0:0.1:10;
y=8*sinc(8*t)-4*sinc(2*t)*cos(6*pi*t);
plot(t,y);
print(hf,"f:\yef.png");

but does not work.

Best Regards
Stefanos Beligiannis
 Create your own email signature DISCLAIMER:This e-mail message and all attachments transmitted with it are intended solely for the use of the addressee and may contain confidential information. If you are not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are notified that any dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately by replying to this message and please delete it from your computer.

Open this post in threaded view
|

RE: Problem in plotting a specific function graph

 > Subject: Problem in plotting a specific function graph > > I am new user of Octave. I wanted to plot a function and I wrote this code:  > pi=3.14159; > t=0:0.1:10; > y=8*sinc(8*t)-4*sinc(2*t)*cos(6*pi*t); > plot(t,y); > print(hf,"f:\yef.png"); > > but does not work. > Can anybody advice?  > > Best Regards > Stefanos Beligiannis Change the "y=...." line to: y=8*sinc(8*t)-4*sinc(2*t).*cos(6*pi*t); Note the use of ".*" instead of "*" for the second multiplication.  "*" is for matrix multiplication while ".*" is used for element-by-element multiplication of the two operands. The print statement should just be "print("f:\yef.png")" to print the current figure. Tony Richardson
Open this post in threaded view
|

Re: Problem in plotting a specific function graph

Well done! It works perfectly!

Thank you Tony

Happy new year and kind regards

Stefanos Beligiannis
Rural & Survey Engineer MSc/Construction Project Manager MSc
 P.O. Box 2572 , Triadi, Thermi, Thessaloniki GREECE 57001
DISCLAIMER:

This e-mail message and all attachments transmitted with it are intended solely for the use of the addressee and may contain confidential information. If you are not the intended recipient, or an employee or agent responsible for delivering this message to the intended recipient, you are notified that any dissemination, distribution, copying, or other use of this message or its attachments is strictly prohibited. If you have received this message in error, please notify the sender immediately by replying to this message and please delete it from your computer.

On Wednesday, January 2, 2019, 5:15:29 PM GMT+2, Richardson, Anthony <[hidden email]> wrote:

> Subject: Problem in plotting a specific function graph
>
> I am new user of Octave. I wanted to plot a function and I wrote this code:
> pi=3.14159;
> t=0:0.1:10;
> y=8*sinc(8*t)-4*sinc(2*t)*cos(6*pi*t);
> plot(t,y);
> print(hf,"f:\yef.png");
>
> but does not work.
>
> Best Regards
> Stefanos Beligiannis

Change the "y=...." line to:

y=8*sinc(8*t)-4*sinc(2*t).*cos(6*pi*t);

Note the use of ".*" instead of "*" for the second multiplication.  "*" is for matrix multiplication while ".*" is used for element-by-element multiplication of the two operands.
The print statement should just be "print("f:\yef.png")" to print the current figure.

Tony Richardson