[Scilab-users] Code problem fft-ifft

Lester Anderson arctica1963 at gmail.com
Mon Aug 26 14:29:00 CEST 2013


I am not sure about the logic with some of these Mathcad files, have a
number to deal with in various forms.

The result for calc_grv is invalid because it should compute all values on
the profiel to npts

The PDF I loaded before shows what it is meant to generate

Checked the loading and plotting of the inputs:

//Read in topography and free-air gravity filesnpts=128Topo =
read('C:\Users\Lester\Documents\Scilab_functions\Geoscience\'+'haw_topo.prn',-1,2);Grav
= read('C:\Users\Lester\Documents\Scilab_functions\Geoscience\'+'haw_grv.prn',-1,2);Topo(:,1)=Topo(:,1)*1000;
Grav(:,1)=Grav(:,1)*1000;
dx = (Grav($,1)-Grav(1,1))/(npts-1);XKint = 2*%pi/((npts-1)*dx);Xint =
(Grav($,1)-Grav(1,1))/(npts-1);
for i=1:npts
    x1(i) = Topo(1,1)+(i-1)*Xint;end
obs_topo = interp1(Topo(:,1),Topo(:,2),x1,'linear');obs_grav =
interp1(Grav(:,1),Grav(:,2),x1,'linear');
k = 0:1:npts-1;
//Plot input files - ignore labels/scalescf(0)clf(0)xlabel("Distance
(km)");ylabel("gravity");
set(gca(),"auto_clear","off")a=gca();a.x_location="bottom";a.axes_reverse=["off","off","off"];plot(k.*Xint/1000,obs_grav,'m');plot(k.*Xint/1000,obs_topo,'b');legend(['bathymetry';'gravity'],4);


The plots of the input data (attached) show the data is read in fine. The
issue is somewhere in the computation, which at least narrows the problem.

Cheers
Lester


On 26 August 2013 12:40, Antoine Monmayrant <antoine.monmayrant at laas.fr>wrote:

> On 26/08/2013 11:03, Lester Anderson wrote:
>
>> Hi Antoine,
>>
>> The prn files are just plain text files, no idea why they were given prn
>> as
>> an extension, that's how they came with the Mathcad code. They can be
>> loaded into Notepad with no problem)
>>
>> The complex issue is coming from the forward and inverse fft as you say. I
>> am kind of suspicious if it is actually loading the data files properly?
>>
>> c = fft(obs_topo1); =  COMPLEX
>> k = 0:1:npts-1;
>> phik = (D*(k*XKint)^4/(g*(rho_m-rho_**c))+1)^-1;Zflexure =
>> (2*%pi*G*1e5)*(rho_c-rho_w).***exp(-k*XKint*mean_depth).*(1-**
>> phik.*exp(-XKint*ocean_thick))**;
>> factork = Zflexure * c; = COMPLEX (single value eg
>> -4.490857598202565E-10-8.**427771813321494E-11*%i)
>>
> Well, I don't know exactly what this means :
>
>  calc_grv = ifft(factork) = COMPLEX - this should be a real set of values.
>>
> factork is a constant ie a 1x1 matrix and I don't see what it means to
> take the fft or the ifft of a constant!
>
> Antoine
>
>>
>>
>> Cheers
>> Lester
>>
>>
>>
>>
>> On 26 August 2013 09:24, Antoine Monmayrant <antoine.monmayrant at laas.fr>*
>> *wrote:
>>
>>    On 25/08/2013 12:45, Lester Anderson wrote:
>>>
>>> Hi all,
>>>
>>> I am attempting to code up a Mathcad file into Scilab and it should be
>>> straightforward, but for some reason it is not working as it should. And
>>> checking the variable values, some are still complex as output from the
>>> fft/ifft runs - the inputs look right as far as I can see.
>>>
>>>   I cannot open the prn files and it's thus difficult for me to check
>>> your
>>> data.
>>> What do you mean by still complex?
>>> When you run fft or ifft on a real dataset, the output is complex, that's
>>> to be expected.
>>> Maybe (it's just a wild guess) you ended up with complex values that have
>>> an imaginary part that is zero.
>>> Scilab still consider these values to be complex.
>>>
>>> Antoine
>>>
>>>
>>> If someone can see what the issue is and a solution, that would be great.
>>>
>>> Attached my quick attempt at converting the Mathcad code (see PDF) and
>>> the
>>> input profile data (*.prn files)
>>>
>>> Cheers
>>>
>>> Lester
>>>
>>>
>>>
>>> ______________________________**_________________
>>> users mailing listusers at lists.scilab.**orghttp://lists.scilab.org/**
>>> mailman/listinfo/users <http://lists.scilab.org/mailman/listinfo/users>
>>>
>>>
>>>
>>>
>>>
>>> ______________________________**_________________
>>> users mailing list
>>> users at lists.scilab.org
>>> http://lists.scilab.org/**mailman/listinfo/users<http://lists.scilab.org/mailman/listinfo/users>
>>>
>>>
>>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20130826/1bfc5403/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4_1b.jpeg
Type: image/jpeg
Size: 35021 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20130826/1bfc5403/attachment.jpeg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 4_1a.jpeg
Type: image/jpeg
Size: 35514 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20130826/1bfc5403/attachment-0001.jpeg>


More information about the users mailing list