Hi,
I'm using the fwhm function to calculate the full width at half maximum of some records. the problem is the function works till it reach some odd values where the wave has a strange distribution (e.g. 1778,1398,1047,1165,1190,805,423,255,212,209,200,190, 193,194,192,192). so the function is crashed with the following massage
((("Subscript indices must either be real positive integers or logicals.
Error in fwhm (line 87)
m = (f(index-1) - f(index))/(x(index-1) - x(index));)))
What type of modifications should I carry out to avoid such problem?
regards
Ashraf
k-Wave
A MATLAB toolbox for the time-domain
simulation of acoustic wave fields
Full width half maximum (fwham)
(7 posts) (2 voices)-
Posted 11 years ago #
-
Hi Ashraf,
The function cannot find the full-width at half maximum if the input distribution doesn't decrease to half the maximum on both sides of the peak (for example, if it is monotonically decreasing). For the example you give, I get the error message
left half maximum not found
. Do you get the same message? One possibility to stop the function throwing an error when the input distribution is not compatible would be to setfwhm_val
to zero and then exit the function usingreturn
instead of callingerror
.Brad
Posted 11 years ago # -
Thanks Brad for the help.
I resolved the problem by reorganizing the initial data.
However, when I calculated the fwhm for a matrix this value is changed according to the size of the matrix, or let's say with the number of variables in the matrix. For example, if I am calcultaing the fwhm for m1 and m2 (m1 represent the data of wave 1 and m2 respresnt the data of wave 2) and t1 and t2 represents the time to m1 and m2 respectivel, the values of fwhm was changed completely if i applied the fwhm model m1 alone or if i applied it to both (m1 and m2, as a matrix and not a vector), which is not logical if i am using the same values all the time.
m1 = (145,141,167,1012,2044,1874,1029,463,277,239,229,224,222,229,222,212)
m2 = (141,149,466,1762,2186,1521,733,376,274,252,244,234,237,241,230,227)
t1 and t2 is time intervals in 2010 ps.
thanks againPosted 11 years ago # -
The current version of
fwhm
is not vectorised, so won't give the correct output for a matrix input forf
. You could look into the source code and modify it for this case, or call the function in afor
loop.Hope that helps,
Brad.
Posted 11 years ago # -
Thanks Brady,
I'll try to call the function in a for loop to solve this issue. I saw also that K-wave allows for depicting voxelPlot, which is very interesting for me. In my work, my idea is to perform a voxel 3D space with K-means clustering to look for difference rock structure. so, what advices you could give me, and what programs i may use for this mission.
regards,
AshrafPosted 11 years ago # -
Dear Brady,
I have some problems with fwhm, mainly in the following two cases:
First, in some cases my data shows a maximum compound of two neighbour points (e.g. 142 149 153 176 252 252 200 160 147 142 140 149 151 149 151 145), and as you can see the maximum is two values of 252. In this case, the function us failed and the fowllowing massage is received:
"Error using <
Matrix dimensions must agree."Second, if the maximum value in my variable is less than 300 (e.g. 144 147 161 192 195 177 153 148 147 143 144 141 146 152 152 148), again the fwhm fails and the following massage is received:
"Error using fwhm (line 64)
left half maximum not found"So, what advice you may give me and how can I resolve this problem?
Thanks again and waiting to hear from you
Regards,Ashraf
Posted 11 years ago # -
The function
fwhm
will not work for both the discrete data sets you mention as they do not drop to half the maximum value. You should see the message'left half maximum not found'
which is correct.Brad.
Posted 11 years ago #
Reply
You must log in to post.