It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Could you help me to write matlab simple code for k-means algorithm without using the algorithm in matlab toolbox ? So i want to work with array and plot the clusters with unique colors. For example i have an array=[1 2; 3 4 ; 5 6] with 2 clusters; some points will be red some points are blue at the end the program should plot the array in axis. then using the k-means algorithm. at the end. plot clusters in graphical interface.
can you help me?
If you want to see how MATLAB does it, type
edit kmeans
into the command window. This might give you some hints.
An easier place to start would probably be the wikipedia page, which has the basic algorithm succinctly outlined.
Related
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I'm trying to write a matlab program which is able to a random walk, but each step/vector has the same length and the thing that determines the direction is a "random" angle. The angle is not quite random since it has some specific boundary conditions. I'm fairly new to matlab, so if anybody have tips or links to webpages feel free to post them here.
Use the function rand(1) to generate an observation of a uniform random variable drawn from the range [0,1]. You can then convert this variable into the range of your angles. The code below might do the trick.
randVal = rand(1); % Generate observation of random variable
randAngle = randVal*(maxAngle-minAngle) + minAngle; % Map observation to angle
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Our teacher wants us to print at Matlab a graph that plots, in the x axis, the quality factor, and on the y axis the mean square error. The image is the known "lenna.jpg".
I've searched and found how to find the mse, but I didn't find anything that helps me on how we find the quality factor.
So, can you please tell me in Matlab code, how to find these 2 things and how to display them in a graph?
Thanks in advance.
I don't have matlab available right now, but I think the following should work:
original=imread('lena.jpg');
mse=zeros(1,100);
for q = 1:100
tempFile = sprintf('lena%03d.jpg', q);
imwrite(original, tempfile, 'quality', q);
thisOne = imread(tempfile);
mse(q) = sum((original - thisOne).^2)/numel(thisOne);
end
figure
plot(1:100, mse)
xlabel 'quality factor'
ylabel 'MSE'
title 'Degradation of Lena.jpg with quality factor'
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
In order to do a quadratic regression on a rather large data set I would like to solve the following equation using svd(singular value decomposition):
B(nx1)=A(nx3)*X(3x1)
I am thinking to use matlab for that, any tips? the goal is to compute matrix X
It seems that what you call quadratic regression is actually the minimal square error regression. In this case the computation is very easy:
1) Multiply both left sides by A'(3xn) arriving to
A'(3xn)B(nx1) = A'(3xn)A(nx3) X(3x1)
2) Now multiply both left sides by the inverse of A'(nx1) A(nx3) arriving to
inv(A'(3xn)A(nx3))A'(3xn)B(nx1) = X(3x1)
3) Now use svd to evaluate the inverse above, see Most efficient matrix inversion in MATLAB
See also Minimizing error of a formula in MATLAB (Least squares?)
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a vector of values corresponding to the measured data and I want to predict the next values. How can I do that? I know that is possible with Kalman filter but it might be an easier way to do. Here is a plot of the data and I want to predict next values:
Try exponential smoothing, e.g., double exponential smoothing or Holt-Winters method. Basically you try to learn the trend of the data.
I have some sample python code in this post.
On the other hand, if you know the movement/observation model of the underline variable, for sure, kalman will give you much better predictions as #tomasz74 pointed out.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Why is Gaussian smoothing commonly used with edge detection?
What is the most suitable smoothing method for an edge detection algorithm? Is it Gaussian smoothing? If so, why?
A simple google with your own question header would've answered your question.
Basically to avoid noise affecting detection.
"Because these kernels are approximating a second derivative measurement on the image, they are very sensitive to noise. To counter this, the image is often Gaussian smoothed before applying the Laplacian filter."
from .. http://homepages.inf.ed.ac.uk/rbf/HIPR2/log.htm