Cart | Help
 You are here: NI Home > NI Developer Zone > NI Discussion Forums Select Community English Français Italiano 日本語 한국어 Español 简体中文 繁体中文 Português (BR)

Member
Posts: 37

# Question about how AmpPhaseSpectrum works

Hi!

I'm using AmpPhaseSpectrum and i was wondering how it works and what i can get from it.

For example, I use SinePattern to create a sine : SinePattern(nb_pts,5,ph1,sine1)

Then if I compute the spectrum what shall i get in the phase chart of AmpPhaseSpectrum?

Knowing that SinePattern computes the sine this way (according to the help browser of LabWindows):

amp*sin(2*pi*i*cycles/nb_pts+pi*phase/180).

Shall I get "phase"? "pi*phase/180"? or "2*pi*i*cycles/nb_pts+pi*phase/180"?

_tren_

Member
Posts: 37

# Re : Question about how AmpPhaseSpectrum works

Moreover, if i take amp[k] and ph[k] from the AmpPhaseSpectrum and use the mto generate sinepattern(nb_pts,amp[k],ph[k],k,tab), wouil I have something? Because I've tried this method but nothing appears on the graph when I want to plot tab...

Ideas?

If you want the code I can post it.

Thanks!

Member
Posts: 37

# Re : Question about how AmpPhaseSpectrum works

Ok, I finally post the code. In case of...

```void Afficher_Reconstruction(double sig[], double amp[],double ph[])
{
int nb_ele, k,i,j;
double **tab,sine[nb_pts]={0};
nb_ele=sizeof(amp)/sizeof(amp[0]);
tab=malloc(nb_ele*sizeof(double));

for(k=0;k<nb_ele;k++)
{
tab[k]=malloc(nb_pts*sizeof(double));
for(j=0;j<nb_pts;j++)
{
tab[k][j]=0.0;

}

}
for(k=0;k<nb_ele;k++)
{

for(i=0;i<nb_pts;i++)
{
SinePattern (nb_pts, amp[k], ph[k], k, tab[k]);
//SineWave (nb_pts, amp[k],k*1.0/nb_pts, &ph[k], tab[k]);
sine[i]=sine[i]+tab[k][i];

}

}

PlotWaveform (p_rec, recpanel_graphrecon, sine, nb_pts, VAL_DOUBLE, 1.0, 0.0, 0.0, 1, VAL_THIN_LINE,VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);

free(tab);
}```

Active Participant
Posts: 300

# Re : Question about how AmpPhaseSpectrum works

[ Edited ]

Hi,

Thank you for posting your question on National Instruments' Forums.

I'm not sure I really understand what your question is.

What do you want to obtain in the end ? a reconstruction of your initial sine wave using the parameters you get from the AmpPhaseSpectrum function ?

Could you elaborate a little on your issue so that I would be able to help you ?

You can write in french if needed.

Best regards,

Guillaume H.
National Instruments France

>> NIDays 2011, le mardi 8 février au CNIT de Paris La Défense

Member
Posts: 37

# Re : Question about how AmpPhaseSpectrum works

Bonjour,

C'est exactement ça je souhaite calculer le spectre de phase grâce à AmpPhaseSpectrum et donc récuperer deux tableaux : un d'amplitude et un de phase.

Et le problème est : comment faire pour recréer le sinus initial grâce à ces deux tableaux. Le but étant de faire une décomposition harmonique de sgnaux plus complexes et de poouvoir ensuite reconstruire chaque harmonique et en faire la somme pour retoruver le signal originel.

D'où la question : peut-on écrire  SinePattern(nb_pts,amp[k],ph[k],k,sine) pour reconstruire le kième harmonique.

Merci,

_trent_

Member
Posts: 37

# Re : Question about how AmpPhaseSpectrum works

Une petite relance du post

Member
Posts: 37

# Re : Question about how AmpPhaseSpectrum works

Du coup non? personne ne sait?