Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am using the meshgrid function in Matlab (v. R2011b) to plot uneven thicknesses data (z) onto a long (x) and lat (y) grid before interpolating and taking an average.
(i) I have defined the spacing for meshgrid but do not know if this is evenly spaced, as the values are different in each dimension (x = 0.00025, and y = 0.0005)? What are the units for this spacing? If this is not even, are there any suggestions of what the spacing should be to create an even grid?
(ii) If this is an even grid, can anyone briefly explain how this is possible given that there are different numbers in the x and y direction?
[xi, yi] = meshgrid(25.32473:0.00025:25.426483, 36.363799:0.0005:36.49821)
There is a definition of uniform grid, where the size of the grid remains the same throughout. meshgrid will always produce a uniform grid. The x-direction and y-direction grid increments can differ in this case. You should not worry about the the increments as such if it solves your use-case.
The unit of increment is same as the unit of axis. For example, if the unit of the axis is meters, then the unit of increment would be 0.005 meters, if your increment size if 0.005.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
distance = [10:.1:30];
norm_dist = normpdf(distance,20,2);
I am trying to generate x,y,z coordinates from the above range of normally distributed values but don't know how to do. Please help.
The normal_dist variable generates values in a normally distributed fashion. I want to use these values to randomly generate the x,y,z, coordinates values. The separate x,y,z values need to be generated not a 3-D array
If I understand your question correctly, you need to use meshgrid function as well
distance = [10:.1:30];
[X,Y,Z] = meshgrid(distance);
F = normpdf(X,20,2);
As a result you'll get 3d grid with those numbers
meshgrid() creates a matrix you can use for further calculations. Probably you will need to make normpdf dependent on X, Y, Z at the same time, e.g.
F = normpdf(X.^2+Y.^2+Z.^2,20,2)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
i want to show the difference value between pixels in same position in successive frames (for example 100 frames),
is it possible to use standard deviation value for determine the number of pixels above or below of this value in successive frames for each pixel position?
or is there another method to show the value of pixels difference in same position in successive frames?
If your image data is the same dimension for each frame, then you can simply concatenate all of your data along a given dimension. Below I will use the 4th dimension since your data may actually be RGB data.
% Assumes that your input data is a cell array of images
combined = cat(4, images{:});
The dimension of this data is now [nRows, nColumns, nChannels, nTime].
Then you can specify the dimension in which to apply many operations in MATLAB. For example if you want to find the differences over time you could use the diff function (Note the specification of the 4th dimension as the third argument):
differences = diff(combined, [], 4);
Similarly you could compute the standard deviation of a pixel over time (Again specifying that you want standard deviation along the 4th dimension).
std_over_time = std(combined, 0, 4);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have this function
Y=fft(y); %fourier transformation
n=size(y,2)/2;
AS=abs(Y)/n; %absolute value
set(figure, 'Position', [0 0 500 300]) %left,bottom,width,height
freq=(0:79)/(2*n*dt);
stem(freq,AS(1:80));
I don't want circles around abscissa axis. I want them only on top of graph.
You can skip plotting points where AS would be equal to 0. Simply set these values to NaN, then plot your graph:
Y=fft(y); %fourier transformation
n=size(y,2)/2;
AS=abs(Y)/n; %absolute value
set(figure, 'Position', [0 0 500 300]) %left,bottom,width,height
freq=(0:79)/(2*n*dt);
%// NEW
ASval = AS(1:80);
ASval(ASval == 0) = NaN;
stem(freq,ASval);
What will happen is that any points that are exactly 0 will not be plotted due to the insertion of NaN. Any values that are non-zero will be plotted by stem normally.
In general, due to floating point precision, looking for elements that are exactly 0 may not bode well. As such, it is good to check to see if values are within a specified threshold, and if they are, set these values to NaN. Because your data is strictly positive, there isn't a need to check for values that are approaching from the negative side of the horizontal axis. As noted in your comments, you used 0.15. Therefore, you would simply do this instead of what I had above:
%// NEW
ASval = AS(1:80);
ASval(ASval < 0.15) = NaN;
stem(freq,ASval);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have trouble with the probability density function (p.d.f) of a log-normal distribution. I really need your help. As defined by wikipedia:
http://en.wikipedia.org/wiki/Log-normal_distribution#Probability_density_function
The probability density function of a log-normal distribution is:
My problem is, how to define x variable in MATLAB? Thanks for your help!
If you have the Stats toolbox, you can just use lognpdf:
y = lognpdf(x,mu,sigma);
Though this is a very simple function - fully vectorized, it's effectively just:
y = exp(-0.5*((log(x)-mu)./sigma).^2)./(x.*sqrt(2*pi).*sigma);
But you may want to check that x > 0 and sig > 0. To create this plot on the Wikipedia article that you cited, you can do:
mu = 0;
sigma = [1;0.5;0.25];
x = 0:0.01:3;
y = lognpdf([x;x;x],mu,sigma(:,ones(1,length(x))));
figure; plot(x,y);
When your question asks about defining x, maybe you're actually looking for log-normally distributed random variables, i.e., you want to sample randomly from the log-normal PDF/distribution? In that case you can use lognrnd:
r = lognrnd(mu,sigma);
I'm confused, like you can do this in a one-liner,
fun = #(x,mu,sigma) (1./(x*sigma*sqrt(2*pi))).*exp( -(power((log(x)-mu),2))/(2*power(sigma,2)))
x is any value that satisfies x > 0, the pdf tells you via Wikipedia
In probability theory, a probability density function (pdf), or
density of a continuous random variable, is a function that describes
the relative likelihood for this random variable to take on a given
value.
So any value x given to the log-normal pdf tells you tel relative likelihood that a random variable could be that value.
Consider this toy example:
mu = 1;
sigma = 10;
x = logspace(-2,0,10);
plot( x, fun(x,1,10) )
From this plot as x gets closer to zero, it's relative likelihood of actually taking on that value increases. DISCLAIMER I just threw that function together, it needs to be checked for accuracy, the preceding was for illustration only.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm implementing metric rectification of an image with projective distortion in the following manner:
From the original image I'm finding two sets of parallel lines and finding their intersection points (the vanishing points at infinity).
I'm selecting five non-collinear points on a circle to be fit to a conic, then I'm checking where that conic intersects the line at infinity using the aforementioned points.
I use those points to find the distorted dual degenerate conic.
Theoretically, since the distorted conic is determined by C*'=HC*H' (C* is the dual degenerate conic, ' is transpose, H is my homography), I should be able to run SVD to determine H. Undistorted, C* is a 3x3 identity matrix with the last element on the diagonal zero. However, if I run SVD I don't get ones in the diagonal matrix. For some matrices I can avoid this by using Cholesky factorization instead (which factors to C*'=HH' which, at least for this, is mostly okay) but this requires a matrix that's positive definite. Is there a way to distribute the scale inside the diagonal matrix returned in SVD equally into the U and V' matrices while keeping them the same? (e.g. U = V).
I'm using MATLAB for this. I'm sure I'm missing something obvious...
The lack of positive definiteness of the resulting matrices is due to noise, as the image used had too much radial distortion rendering even the selection of many points on the circle fairly useless in this approach.
The point missed in the SVD approach was to remove the scale from the diagonal component by right and left multiplying by the square root of the diagonal matrix (with the last diagonal element set to 1, since that singular value should be zero but a zero component there would not yield correct results).