Using gausswin function and iFT'ing data
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Cheggers
el 8 de Sept. de 2021
Respondida: William Rose
el 8 de Sept. de 2021
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 comentarios
William Rose
el 8 de Sept. de 2021
@Cheggers, I don;t understand the last code segment in your posting, which begins with
function FID=windowFID(FID,sw,type,wp)
Is this whole thing a declaration of function windowFID? It's indented, like a function declaration might be. But you define the values for the passed parameters, and you call the function. So this is not a function declaration. Then where is the declaration of windowFID()?
The line of code above has FID as a parameter passed to the function (inside the ()), AND it has FID as the value returned (left side of the "="). That is a mistake. I cannot figure out what function windowFID is supposed to do, because it is not clearly declared or defined.
You say "However in practice this doesnt work. I am trying to find out why." What exactly does not work? Do you get an error message? If so, what, and in repsonse to what input? If there's not an error message, then how do you know it doesn't work?
Respuesta aceptada
William Rose
el 8 de Sept. de 2021
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.
Más respuestas (1)
William Rose
el 8 de Sept. de 2021
@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.
0 comentarios
Ver también
Categorías
Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!