Problem in plotting a specific function graph

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem in plotting a specific function graph

Stefanos Beligiannis
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

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.




Reply | Threaded
Open this post in threaded view
|

RE: Problem in plotting a specific function graph

Tony Richardson


> 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


Reply | Threaded
Open this post in threaded view
|

Re: Problem in plotting a specific function graph

Stefanos Beligiannis
Well done! It works perfectly!

Thank you Tony

Happy new year and kind regards

photo
Stefanos Beligiannis
Rural & Survey Engineer MSc/Construction Project Manager MSc

+30 231 550 4700 | +30 697 299 3938, +30 694 805 9589, +44 780 117 3921 | [hidden email]

http://smpel9.wixsite.com/stefanosbeligiannis | Skype: stefanos.beligiannis

P.O. Box 2572 , Triadi, Thermi, Thessaloniki GREECE 57001
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.




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.
> 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