# Using gausswin function and iFT'ing data

조회 수: 5(최근 30일)
Cheggers 2021년 9월 8일
답변: William Rose 2021년 9월 8일
I have a problem using this function to be able to achieve the results i would like.
I have a set of x-y coordinates and a z value for each given coordinate. This allows my to plot a contour plot/surf plot which are my end result goals.
I problem is i have to inverse fourier transform my data, apply a weighting function, then fourier transform is back.
My data is A, this is a double containing all the data i need. (1,2:end) is all the x values of my data, (2:end,1) is all the y values of my data.
A small section of this looks like the following
A is 122x172 with (1,1) being a 0 that is not used
0 -2 -1.9 -1.8
-39764.6294117647 6.08070785739910e-83 8.04009418418979e-75 3.91087450307717e-67
-39084.8921568627 6.07818104427524e-83 8.03675320347305e-75 3.90924942953431e-67
-38405.1549019608 5.50118311043384e-83 7.27382951311617e-75 3.53814725422373e-67
-37725.4176470588 4.49386618815605e-83 5.94192547428560e-75 2.89028115830385e-67
-37045.6803921569 3.16593091252869e-83 4.18608993847438e-75 2.03620535151014e-67
-36365.9431372549 2.02382654883846e-83 2.67596412453151e-75 1.30164642909436e-67
-35686.2058823529 8.34531604179285e-84 1.10344602963960e-75 5.36743453841054e-68
This is then made into something that can be plotted using the following
a = A(1,2:end);
b = A(2:end,1);
[X,Y]=meshgrid(a,b);
Z=A(2:end,2:end) ;
contour(X,Y,Z)
This works well.
I have then tried to inverse fourier transform this data using this code.
preweight = []
for yl = 1:121;
singleyline = Z(yl,:);
ifty = iFT(singleyline);
preweight(yl,:) = ifty;
clear ifty;
end
Which produces me a 121x171 complex double which is fine.
When i take a sample of this data and plot is vs just the number of points.
test = preweight(1,:) %this gives a 171 length array
testx = 1:171
plot (test,testx)
This gives me the following plot I then need to apply the following weighting function.
function FID=windowFID(FID,sw,type,wp)
%in this case the type was 'Gaussian' which does the following. With FID
%being 'test' for example. SW and WP for this are set to be 200000 and 5
wp=5
sw = 200000
window=generate(sigwin.gausswin(length(FID)*2,wp));
window=window(length(FID)+1:length(FID)*2,:);
%what this looks like in the actual code is below as the above is a
%created function
weightedtest=windowFID(test,sw,wt,wp);
% then
data = FT(weightedtest)
This ideally would give me a weighted set of data which i could then fourier transform back into plotable data.
I could put these sets into 1-2 for loops for all 121 y values.
This would then given me A again as the start but with slightly weighted values, perefect.
However in practice this doesnt work. I am trying to find out why. I think a key reason being is that the FID (this being 'preweight') i produce is mirrored (i tried getting rid of the right side of the mirror and that changes the look of the data once it has been FT'd again so no good) where as the data where the code was previously written for was not mirrored in this way (think just the left half of the above graph). To briefly explain why this is the case the purpose of this code is to try to artificially produce a 3D graph similar to one obtained doing an analytical experiment. The experiment prodcues a FID and the simulated once produces a mirrored one.
If anyone has any insight it would be greatly appreciated.
P.S. If i have missed anything out or it is unclean please ask.
##### 댓글 수: 2표시숨기기 이전 댓글 수: 1
Cheggers 2021년 9월 8일
Ahh that was my mistake
To reorder it properly it should be:
function FID=windowFID(FID,sw,type,wp)
%in this case the type was 'Gaussian' which does the following. With FID
%being 'test' for example. SW and WP for this are set to be 200000 and 5
if 'Gaussian'
window=generate(sigwin.gausswin(length(FID)*2,wp));
window=window(length(FID)+1:length(FID)*2,:);
%what this looks like in the actual code is below as the above is a
%created function
wt = 'Gaussian'
wp=5
sw = 200000
weightedtest=windowFID(test,sw,wt,wp);
% then
data = FT(weightedtest) Here is an imagine fo the experimental data FID being weighted using Gaussian as per the above code. I havnt run my data though it yet because my data is mirrored unlike the above FID. So i believe what would happen would be the left side would be multiplied correctly however the right hand side would be zero'd. I am going to run it tomorrow at work to make sure but i am confident that this will be the outcome.

댓글을 달려면 로그인하십시오.

### 채택된 답변

William Rose 2021년 9월 8일
OK, I am glad if my earlier comment served as an answer to your probelem. I still think function windowFID() has a problem:
function FID=windowFID(FID,sw,type,wp)
The function declaration uses FID as the return value and as one of the arguments.
Also, the statement
if 'Gaussian'
is always true. Did you mean to write
if type='Gaussian'
Also, there is no end after the if.
##### 댓글 수: 1표시숨기기 없음
Cheggers 2021년 9월 8일
Hi so there is more to that function such as the other if for differnt types and it is all followed by end. i just didnt want to add all that code to an already long question.
'The function declaration uses FID as the return value and as one of the arguments.'
Surely this is normal as the function process the FID then overrites the variable to the new processed one?

댓글을 달려면 로그인하십시오.

### 추가 답변(1개)

William Rose 2021년 9월 8일
@Cheggers, you are correct, you can use the same variable name for an input to the function and for an output from the function. It would not be my choice, because I am easily confused.

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!