필터 지우기
필터 지우기

matlab determine a curve

조회 수: 5 (최근 30일)
joo
joo 2012년 9월 16일
Imagine i have an original plot with superimposed '8' shape curves (the curves are all different but similar to the '8' shape). Does anyone know how to obtain a mean curve having a matrix with the correspondent x,y points from the original plot? I mean, I pretend a medium single curve.
Any code or just ideas would be very very helpful for me. Thank you very very much!
  댓글 수: 7
Image Analyst
Image Analyst 2012년 9월 18일
Can you post your code where you use xlsread to read it in and loop over each curve to find the left-most part and record its row? And your code to use circshift to align them? Can you do any of that to help us help you?

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2012년 9월 18일
편집: Image Analyst 2012년 9월 18일
You have a little noise on your y-data, as you can see from this example code. You might need to smooth that out first.
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;
format compact;
fontSize = 20;
folder = 'C:\Users\joo\Documents\Temporary';
fullFileName = fullfile(folder, 'livro1.xlsx');
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
[num txt raw] = xlsread(fullFileName);
x = num(:, 1);
y = num(:, 2);
% Plot x
subplot(2,2,1);
plot(x, 'b-');
xlabel('Element Number', 'FontSize', fontSize);
ylabel('X', 'FontSize', fontSize);
title('X', 'FontSize', fontSize);
grid on;
% Plot y
subplot(2,2,2);
plot(y, 'b-');
xlabel('Element Number', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
title('Y', 'FontSize', fontSize);
grid on;
% Plot curves
subplot(2,2,3);
plot(num(:, 1), num(:, 2), 'b-');
title('X', 'FontSize', fontSize);
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
grid on;
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
% Calculate distance from (50,360) of every point.
distances = sqrt((x - 50).^2 - (y - 360).^2)
subplot(2,2,4);
plot(distances, 'b-');
title('Distance from (50, 360)', 'FontSize', fontSize);
xlabel('index', 'FontSize', fontSize);
ylabel('Distances', 'FontSize', fontSize);
grid on;
% Find valleys in distances to find out where it turned around.
[valleys, indexesAtMins] = findpeaks(-distances)
% Plot them.
hold on;
plot(indexesAtMins, -valleys, 'r*');
  댓글 수: 4
joo
joo 2012년 9월 18일
and why do you Calculate distance from (50,360) of every point? thank you very much!
Image Analyst
Image Analyst 2012년 9월 18일
I just answered that. Run my code and look at the graph and I think you'll see why.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

joo
joo 2012년 9월 19일
편집: joo 2012년 9월 19일
image analyst i am sorry to insist but i have been working all these days in this and still i can't understand. i see that in the plot you can vizualize (50,360). but why are these numbers and not for example (55,365)-with this pair the results would be different... i really don't understand where do they come from since i investigated all the results and code and nothing related with (50,360)... i am stucked in this for days. i am so grateful for your help. this is very important for me. thank you so much for your attention.
  댓글 수: 8
joo
joo 2012년 10월 5일
in your code you filter x,y data responsible for the noise/small peaks. you discover this peaks by x^2 +y^2. how can you justify this? shouldn't the noise data be seen only in x and y data alone? how can i justify this filtering?
i am not at all declining your code... i just need to justify the steps, and this is a doubt of mine... can you clear me this last doubt? thank you very much.
Image Analyst
Image Analyst 2012년 10월 5일
I'm calculating the Euclidean distance from some point way off the end of the curve's travel to the points on the curve using the Pythagorean Theorem, which is the sqrt of the sum of the squares. That distance oscillates as the point on the curve gets closer and farther away from the fixed, distant point as the curve point travels.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with MuPAD에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by