MATLAB Answers

Hi, I want the tolerance around this figure, I have posted the code ,where i am getting two figures on the upper and lower halfs of the original figure, which is shown in the attached image.Can anyone tell me what changes i must do ?

10 views (last 30 days)
L K on 9 Feb 2017
Commented: L K on 10 Feb 2017
I have attached two figures
1. Error1.jpeg (which shows two figures on upper and lower half according to the code i posted)
2. correct.jpeg (This is how the figure should look like ,i want it to be projected on top of the original figure)
Here are the images
And here is the code :
file = 'idle_coil_for_imag_real.xlsx' ;
[num,txt,raw] = xlsread(file) ;
imag = num(:,2) ;
real = num(:,1) ;
%[xx,yy] = pol2cart(x,y);
k = convhull(real, imag);
xch = real(k);
ych = imag(k);
%[xCH, yCH] = cart2pol(xch, ych);
plot(xch, ych, 'ro-','LineWidth', 1);
hold on
plot(real,imag,'b*','LineWidth', 1);
%plot(xch, ych, 'ro-',real,imag,'b*');
hold on
% Plot lines for a tolerance band above and below the perfect signal.
tolerance = 0.1; % Whatever you want.
yUpperLimit = ych + tolerance;
yLowerLimit = ych - tolerance;
xUpperLimit = xch + tolerance;
xLowerLimit = xch - tolerance;
plot(xUpperLimit, yUpperLimit, 'g.-', 'LineWidth', 1, 'MarkerSize', 14, 'Color', [0, 0.5, 0]);
plot(xLowerLimit, yLowerLimit, 'g.-', 'LineWidth', 1, 'MarkerSize', 14, 'Color', [0, 0.5, 0]);

Answers (1)

Walter Roberson
Walter Roberson on 9 Feb 2017
You have
tolerance = 0.1; % Whatever you want.
yUpperLimit = ych + tolerance;
0.1 is large compared to your values, so you are shifting the plotting a fair bit.
One approach would be to find the centroid of your signal, and then calculate the difference in coordinates between that and your boundary points. Convert to polar. Multiply the radius by 1.1 and convert back. Add to the centroid to get the new boundary. Likewise, you can multiply the radius by 0.9 instead of 1.1.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!