Transfer function to a Difference equation

Thread Starter

naickej4

Joined Jul 12, 2015
206
Hi,

So you will have to write your own DFT program algorithm?
What language will you be using?
You should learn some program language anyway, but if you have your choice that would be nicer.
Hi Sir,
I think I need to write my own DFT program.
I have no idea what programming language to use and were to start on these type of problems.
I do know C programming but not intense stuff.
What are you thoughts on this Mr AI?
thank you.
 

Thread Starter

naickej4

Joined Jul 12, 2015
206
WOW Sir, that is truly amazing!!!. 200 books. I am sure you must have been a genius while at school and college and you also very polite.
I want to be a part time mathematician, what can I do to do this?
DO you think its worth the while?
regards
Joshy
Hi Josh,

I think start to teach high school maths in your spare time, I used to do that at an orphanage. If your passion is still burning then go for it.
I think maths is used to help others and not kept for yourself ( my opinion).
No use being good at maths and not sharing your knowledge and wisdom unto others.
thank you.
 

MrAl

Joined Jun 17, 2014
11,389
Hi Sir,
I think I need to write my own DFT program.
I have no idea what programming language to use and were to start on these type of problems.
I do know C programming but not intense stuff.
What are you thoughts on this Mr AI?
thank you.

Hi again,

Ok then my questions would be:
1. Do you have a C compiler?
2. Do you know how to set up math equations in C?
3. Do you know how to set up math with complex numbers in C?
4. Do you know how to set up simple loops in C, like for/next loops?

Just out of curiosity, do you know how to set up complex number math using all real variables?
 

Thread Starter

naickej4

Joined Jul 12, 2015
206
Hi again,

Ok then my questions would be:
1. Do you have a C compiler?
2. Do you know how to set up math equations in C?
3. Do you know how to set up math with complex numbers in C?
4. Do you know how to set up simple loops in C, like for/next loops?

Just out of curiosity, do you know how to set up complex number math using all real variables?
Hi Sir,
Yikes...I can honestly tell you.
1. I do have a C compiler.
2. Yes, but very basic
3. No
4. Yes, I know how to use, LOOP (While, For Loop, etc)

I have no idea on how to set up complex number math using real variables.

I am sure willing to learn and research these topics.

thank you.
 

MrAl

Joined Jun 17, 2014
11,389
Hi Sir,
Yikes...I can honestly tell you.
1. I do have a C compiler.
2. Yes, but very basic
3. No
4. Yes, I know how to use, LOOP (While, For Loop, etc)

I have no idea on how to set up complex number math using real variables.

I am sure willing to learn and research these topics.

thank you.

Hello again,

Ok then maybe you would be happier with a pseudo C language that is interpreted not compiled. That would get you going faster i think because then you dont have to learn the more intricate C language and dont have to compile every time you change the program.
Are you interested in doing this? Everything of course would be free to download.

To give an example:

for k=1 to 10 do
printf(1,"%d\n",k)
end for
sleep(2)

The above is a loop that simply prints the value of k, so it would print 10 values on a console screen, then close out after 2 seconds.
What is nice about this language is that you can run the program as soon as you type that program into a common text editor and then save the file. So no compile stage before you can run it. The syntax is also a reduced set.

If you are interested i'll find you a download link.
If you want to use C that's ok too i guess, and just stick to the simpler constructs. I dont know what compiler you use but i use Watcom because it's free. I have an older Microsoft version but dont use it anymore because it's kind of outdated.
 
Last edited:

Thread Starter

naickej4

Joined Jul 12, 2015
206
Hello again,

Ok then maybe you would be happier with a pseudo C language that is interpreted not compiled. That would get you going faster i think because then you dont have to learn the more intricate C language and dont have to compile every time you change the program.
Are you interested in doing this? Everything of course would be free to download.

To give an example:

for k=1 to 10 do
printf(1,"%d\n",k)
end for
sleep(2)

The above is a loop that simply prints the value of k, so it would print 10 values on a console screen, then close out after 2 seconds.
What is nice about this language is that you can run the program as soon as you type that program into a common text editor and then save the file. So no compile stage before you can run it. The syntax is also a reduced set.

If you are interested i'll find you a download link.
If you want to use C that's ok too i guess, and just stick to the simpler constructs. I dont know what compiler you use but i use Watcom because it's free. I have an older Microsoft version but dont use it anymore because it's kind of outdated.
Hi Sir, Anything that is simple to learn n understand.
What to you think is simple from the both?
Yes please can you provide me the link and I will download it.
Thank you very much.
 

Thread Starter

naickej4

Joined Jul 12, 2015
206
Hi Sir,
I silly question:
Does Matlab do the same functionality like what will be done in C or pseudo C language?

This is a quote from one of the study guides:
"Matlab, Matcad, SciLab, Octave and R-Lab are available on the internet for the Linux version of Unix and Windows.
Normal C, Pascal or Basic could also be used."

Thank you.
 

MrAl

Joined Jun 17, 2014
11,389
Hello again,

I dont use Matlab so i cant tell you that. What exactly is it that you want to do, just FFT? If so i would guess that it does it, but i dont know if you can write your own routines in that. It depends if Matlab supports any kind of programming language, and if so do you really want to use that particular language.

Do you want to make your own FFT routines or use the built in functions?
 

Thread Starter

naickej4

Joined Jul 12, 2015
206
Hi Sir. It's not just FFT its also simple programs e.g produce a signal from a 6Hz Sinusoidal.
We write a practical exam on the 29 of August. We have to do the exam on a computer with either of the software that i have mentioned above. I have past exam questions that I can show you and also post. But because time is a large factor here I need to learn the most simplistic programming language that will help me to pass the practical exam which is next month :(
I pray you or others can advice me on the best approach.
Thank you.
 

MrAl

Joined Jun 17, 2014
11,389
Hello again,

Oh well if you are forced to use a certain language or two then you have to use those as you dont have any choice. So i would say Basic is the easiest but i dont think i have a Basic interpreter anymore i just have C compiler and the other language i showed you.
Thus out of those three i would probably have to use C.
I wrote a lot of Basic programs in the past long ago, but that was because that's the only language environment i had. Now that i've used other languages i tend to dislike Basic because it is too basic.
So would you be comfortable working in C for a while? You can do a lot in C including Windows programs, graphing programs, etc.
Programs like graphing programs would take longer to learn however, while simple number crunching would be very quick to learn. You could probably learn how to crunch some numbers real or complex in a day or two. The results you print to the console.

When you say "produce a 6Hz signal" what do you mean by that exactly?
 

Thread Starter

naickej4

Joined Jul 12, 2015
206
Hello again,

Oh well if you are forced to use a certain language or two then you have to use those as you dont have any choice. So i would say Basic is the easiest but i dont think i have a Basic interpreter anymore i just have C compiler and the other language i showed you.
Thus out of those three i would probably have to use C.
I wrote a lot of Basic programs in the past long ago, but that was because that's the only language environment i had. Now that i've used other languages i tend to dislike Basic because it is too basic.
So would you be comfortable working in C for a while? You can do a lot in C including Windows programs, graphing programs, etc.
Programs like graphing programs would take longer to learn however, while simple number crunching would be very quick to learn. You could probably learn how to crunch some numbers real or complex in a day or two. The results you print to the console.

When you say "produce a 6Hz signal" what do you mean by that exactly?
Hi Sir, Thank again for your time taken to help me.
I am going to email the lecturer that is in charge of this subject and ask him more.
From my knowledge and understanding and the example that was given

upload_2016-7-22_10-56-46.png

The below answer was done in Mathlab ( I think). So we need to write these type of programs in any of the given programming languages.

upload_2016-7-22_10-58-1.png
Thank you
 

MrAl

Joined Jun 17, 2014
11,389
Hello again,

Oh ok, well i wasnt sure if you had to actually generate a real life signal or just a program that 'generates' the signal in the program space itself only, not externally like a real signal. A real signal would need an output port of some kind where we would send the generated signal, such as a sound card or a PWM printer port pin or some other output type. That would generate a signal that could be used for testing other equipment for example.
 

Thread Starter

naickej4

Joined Jul 12, 2015
206
Hello again,

Oh ok, well i wasnt sure if you had to actually generate a real life signal or just a program that 'generates' the signal in the program space itself only, not externally like a real signal. A real signal would need an output port of some kind where we would send the generated signal, such as a sound card or a PWM printer port pin or some other output type. That would generate a signal that could be used for testing other equipment for example.
Hi Sir,
Sorry for the misunderstanding.
I still waiting upon the lecturer's email. But I definitely know that I have to create these type of programs for the practical exam. The real life signal creation will be done in my final year. I will need a breadboard and oscilloscope and those other measurement equipment.
Thank you.
 

MrAl

Joined Jun 17, 2014
11,389
Hi,

Ok, well in C you would do almost the same thing after declaring the types, but instead of a graph output you would probably just have the numerical data unless you code for graphing or wanted to create that yourself too.

Something like:

include <math.e> //or whatever is available
double t,y,dt,w,A;
int k;

A=10; //amplitude
dt=0.1; //time step
w=2*pi*5;
for (k=0;k<63;k++)
{
t=dt*(double)k;
y=A*sin(w*t);
//plot points (t,y) with some function
}


That's a rough example you can try if you like.
 

Thread Starter

naickej4

Joined Jul 12, 2015
206
Hi,

Ok, well in C you would do almost the same thing after declaring the types, but instead of a graph output you would probably just have the numerical data unless you code for graphing or wanted to create that yourself too.

Something like:

include <math.e> //or whatever is available
double t,y,dt,w,A;
int k;

A=10; //amplitude
dt=0.1; //time step
w=2*pi*5;
for (k=0;k<63;k++)
{
t=dt*(double)k;
y=A*sin(w*t);
//plot points (t,y) with some function
}


That's a rough example you can try if you like.
Hi Sir,
I am going to try that out and see what I get as the output. Thanks a lot
I will show you and post some of the questions of the past exam.
Is there a good document or search link that will give me the maths commands in C?
I need to learn this ASAP for the practical exam.
Thank you for your time and effort in helping me.
 

MrAl

Joined Jun 17, 2014
11,389
Hi,

There are a ton of documents online that talk about C functions and syntax and all that. For complex math i found this first try:
http://en.cppreference.com/w/c/numeric/complex

I actually never used complex number math in C using the standard include files, i always made my own number crunchers for both real and complex arguments, but this looks interesting so i might try it too maybe tomorrow some time. I'll keep it very very simple and post results here also.
Console applications are very easy to make in C. For Windows applications you have to study the Windows API which would take too long for you to get ready by next month.

Here is a sample program in C. Note function calls may be different for other compilers or include files.


#include <stdlib.h>
#include <math.h>
#include <complex.h>
#include <stdio.h>
#include <dos.h> //for sleep()


void main(void)
{
complex xx,yy;
double y;

xx=Complex(1.0,2.0);
yy=cos(xx);
printf("%f,%f\n",real(xx),imag(xx));
printf("%f,%f\n\n",real(yy),imag(yy));

xx=acos(yy);
printf("%f,%f\n",real(yy),imag(yy));
printf("%f,%f\n\n",real(xx),imag(xx));

xx=Complex(2.0,2.0);
yy=atan(xx);
printf("%f,%f\n",real(xx),imag(xx));
printf("%f,%f\n\n",real(yy),imag(yy));

y=atan2(2.0,2.0);
printf("%1.8f\n",y);

sleep(5);
}

The above prints the following to a console screen:

1.000000,2.000000
2.032723,-3.051898

2.032723,-3.051898
1.000000,2.000000

2.000000,2.000000
1.311223,0.238878

0.78539816
 
Last edited:
Top