Center of Gravity of given file

8 vues (au cours des 30 derniers jours)
MUHAMMAD ANUS
MUHAMMAD ANUS le 11 Août 2021
Commenté : Walter Roberson le 11 Août 2021
Ques. I have to plot the center of gravity for the attached image using the hold on command. I can plot the 'xline' what I don't understand is how to get the co-ordinates of COG and plot them on the same figure where I have my spectrum. Or how to find the y-intercept?
%% Centre of Gravity
x1 = readData{1,1}(:,1);
y1 = readData{1,2}(:,1);
numerator = sum(x1 .* y1);
denominator = sum(y1);
COG = numerator / denominator
figure(2);
hold on; grid on;
plot(x,y,'Color','b','LineWidth',1.5);
xlabel('Wavelength(nm)');
ylabel('Intensity');
title('Initial Spectrum');
ylim([0 0.3]);
xline(COG, 'Color', 'r');
%plot(COG(index), y(index), 'or', 'LineWidth', 2);
%plot(COG, 'or', 'LineWidth', 2, 'MarkerSize', 6);
  2 commentaires
MUHAMMAD ANUS
MUHAMMAD ANUS le 11 Août 2021
Image Analyst
Image Analyst le 11 Août 2021
Data is a 3679 by 2 matrix. How is that an image? Please give code to turn '5.csv' into readData cell array.

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 11 Août 2021
Wrong equation for centre of gravity. When you have uniform density, then the x coordinate of the COG is mean(x) and the y coordinate of the COG is mean(y)
Your COG equation is suitable for the case where you have a line with weights at x1 each of which weighs according to y1, and you are trying to find the COG of the line. However, in that case, there would be no vertical displacement.
  4 commentaires
MUHAMMAD ANUS
MUHAMMAD ANUS le 11 Août 2021
What I have to do after this is compare different spectrums and their COG and analyse / look into the plots to make sense of the data
Walter Roberson
Walter Roberson le 11 Août 2021
Your xline() already marks the COG.
I have no idea what features are important for the purposes of comparing your spectra.
I know that when we were doing Magnetic Resonance Spectrum analysis to see if we could detect various forms of cancer, that the factors that turned out to be statistically important were not at all "flashy"; one of the key indicators turned out to be the ratio of two peaks, one of which just looked like a minor shoulder on water, and the other of which was a common chemical that had a lot of natural variation. Slightly higher levels of 1 combined with lower levels of the other was the key measure. Before us, no-one had ever realized the medical importance of that combination of circumstances.
Because of my experience, I can't make any blanket recommendations such as "mean squared error" or "most prominent peak".
In astronomy, a similarity might be that the key to understanding the classification of a particular star might not be the intensity of a peak by itself, but rather the ratio of several peaks. And that requires domain-specific knowledge of how to process the spectra.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by