How to find the area between two lines of different size matrices and fill that area?
I have two lines that im plotting for a vehicles location. One is the intended path I wanted the vehicle to travel, its a perfectly straight line, the other is the path the vehicle actually took. Its close but not perfect. My end goal is to find how much the vehicle actual path deviated from the intended path as a proxy for navigational accuracy. My idea is that I could calculate the area between the two lines and use that as an indicator for how accuratly the vehicle followed its intended path. When I do this calculation I also want to highlight the difference between the two lines in the graph. This is all part of a much larger program intended for use by the people operating these vehicles. Below is how im plotting the position of both the vehicle and the planned path, I also included a jpg of what the path looks like compared to the intened path.
Ive looked into this and the error I keep getting is:
Specify the coordinates as matrices of the same size or as vectors with the same number of elements.
The problem is, there is only 71 points for the track path and 508486 points for vehicle position, I tried interpolating the track path to make the matrices the same size but I get NaN values for everything after the 71 points so im not sure why thats not working.
I tried patch and fill and got the same error with both. Below is my code:
P = uigetdir(‘C:’);
S1 = dir(fullfile(P,’AHR2.csv’));
S3 = dir(fullfile(P,’CMD.csv’));
F = fullfile(S3.folder,S3.name);
M = readmatrix(F);
F1 = fullfile(S1(k).folder,S1(k).name);
M1 = readmatrix(F1);
TrackLat1 = M(:,10);
TrackLong1 = M(:,11);
Lat2 = M1(:,7);
Long2 = M1(:,8);
TrackLatLong = [TrackLat1, TrackLong1];
[MM, ~, ~] = rmoutliers(TrackLatLong, 1);
TrackLat = MM(:,1);
TrackLong = MM(:,2);
LatLong = [Lat2, Long2];
[MM1, ~, ~] = rmoutliers(LatLong, 1);
Lat1 = MM1(:,1);
Long1 = MM1(:,2);
plot(Long1, Lat1)
hold on
plot(TrackLong, TrackLat)
hold on
X = [Long1;Lat1];
Y = [TrackLong; TrackLat];
patch([X fliplr(X)], [Y fliplr(Y)], ‘red’)
title ‘FAT Position’
legend(‘USV Position’, ‘Mission Plan’)
xlim tight
ylim tight
ylabel ‘Latitude’
xlabel ‘Longitude’
attached is a screen shot of the plot plus a zoomed in section because you might not be able to tell. Thanks in advance for any help I might recieve, if any one has any ideas on a simpler way to do this please let me know!I have two lines that im plotting for a vehicles location. One is the intended path I wanted the vehicle to travel, its a perfectly straight line, the other is the path the vehicle actually took. Its close but not perfect. My end goal is to find how much the vehicle actual path deviated from the intended path as a proxy for navigational accuracy. My idea is that I could calculate the area between the two lines and use that as an indicator for how accuratly the vehicle followed its intended path. When I do this calculation I also want to highlight the difference between the two lines in the graph. This is all part of a much larger program intended for use by the people operating these vehicles. Below is how im plotting the position of both the vehicle and the planned path, I also included a jpg of what the path looks like compared to the intened path.
Ive looked into this and the error I keep getting is:
Specify the coordinates as matrices of the same size or as vectors with the same number of elements.
The problem is, there is only 71 points for the track path and 508486 points for vehicle position, I tried interpolating the track path to make the matrices the same size but I get NaN values for everything after the 71 points so im not sure why thats not working.
I tried patch and fill and got the same error with both. Below is my code:
P = uigetdir(‘C:’);
S1 = dir(fullfile(P,’AHR2.csv’));
S3 = dir(fullfile(P,’CMD.csv’));
F = fullfile(S3.folder,S3.name);
M = readmatrix(F);
F1 = fullfile(S1(k).folder,S1(k).name);
M1 = readmatrix(F1);
TrackLat1 = M(:,10);
TrackLong1 = M(:,11);
Lat2 = M1(:,7);
Long2 = M1(:,8);
TrackLatLong = [TrackLat1, TrackLong1];
[MM, ~, ~] = rmoutliers(TrackLatLong, 1);
TrackLat = MM(:,1);
TrackLong = MM(:,2);
LatLong = [Lat2, Long2];
[MM1, ~, ~] = rmoutliers(LatLong, 1);
Lat1 = MM1(:,1);
Long1 = MM1(:,2);
plot(Long1, Lat1)
hold on
plot(TrackLong, TrackLat)
hold on
X = [Long1;Lat1];
Y = [TrackLong; TrackLat];
patch([X fliplr(X)], [Y fliplr(Y)], ‘red’)
title ‘FAT Position’
legend(‘USV Position’, ‘Mission Plan’)
xlim tight
ylim tight
ylabel ‘Latitude’
xlabel ‘Longitude’
attached is a screen shot of the plot plus a zoomed in section because you might not be able to tell. Thanks in advance for any help I might recieve, if any one has any ideas on a simpler way to do this please let me know! I have two lines that im plotting for a vehicles location. One is the intended path I wanted the vehicle to travel, its a perfectly straight line, the other is the path the vehicle actually took. Its close but not perfect. My end goal is to find how much the vehicle actual path deviated from the intended path as a proxy for navigational accuracy. My idea is that I could calculate the area between the two lines and use that as an indicator for how accuratly the vehicle followed its intended path. When I do this calculation I also want to highlight the difference between the two lines in the graph. This is all part of a much larger program intended for use by the people operating these vehicles. Below is how im plotting the position of both the vehicle and the planned path, I also included a jpg of what the path looks like compared to the intened path.
Ive looked into this and the error I keep getting is:
Specify the coordinates as matrices of the same size or as vectors with the same number of elements.
The problem is, there is only 71 points for the track path and 508486 points for vehicle position, I tried interpolating the track path to make the matrices the same size but I get NaN values for everything after the 71 points so im not sure why thats not working.
I tried patch and fill and got the same error with both. Below is my code:
P = uigetdir(‘C:’);
S1 = dir(fullfile(P,’AHR2.csv’));
S3 = dir(fullfile(P,’CMD.csv’));
F = fullfile(S3.folder,S3.name);
M = readmatrix(F);
F1 = fullfile(S1(k).folder,S1(k).name);
M1 = readmatrix(F1);
TrackLat1 = M(:,10);
TrackLong1 = M(:,11);
Lat2 = M1(:,7);
Long2 = M1(:,8);
TrackLatLong = [TrackLat1, TrackLong1];
[MM, ~, ~] = rmoutliers(TrackLatLong, 1);
TrackLat = MM(:,1);
TrackLong = MM(:,2);
LatLong = [Lat2, Long2];
[MM1, ~, ~] = rmoutliers(LatLong, 1);
Lat1 = MM1(:,1);
Long1 = MM1(:,2);
plot(Long1, Lat1)
hold on
plot(TrackLong, TrackLat)
hold on
X = [Long1;Lat1];
Y = [TrackLong; TrackLat];
patch([X fliplr(X)], [Y fliplr(Y)], ‘red’)
title ‘FAT Position’
legend(‘USV Position’, ‘Mission Plan’)
xlim tight
ylim tight
ylabel ‘Latitude’
xlabel ‘Longitude’
attached is a screen shot of the plot plus a zoomed in section because you might not be able to tell. Thanks in advance for any help I might recieve, if any one has any ideas on a simpler way to do this please let me know! patch MATLAB Answers — New Questions