Problems storing, processing and displaying ginput value?

I've got the following code:
clear
clc
close all
Map=imread('Map.Jpg');
imshow(Map);
hold on;
A = zeros(1, 24);
B = zeros(1, 24);
C = zeros(1, 24);
uiwait(msgbox('Choose Point A'));
[x,y] = ginput(1); %hold on;
plot(x,y,'r+', 'MarkerSize', 50);
A = ginput(1);
C = pdist2(A,B);
%Value1 = ginput(1);
uiwait(msgbox('Choose Point B'));
[x,y] = ginput(1); %hold on;
plot(x,y,'r+', 'MarkerSize', 50);
B = ginput(1);
%Value2 = ginput(1);
disp ('Values:')
disp(A);
disp(B);
disp(C);
I'm trying to get it so that: a) I only need to click once instead of twice to get points b) allows me to perform the pdist calculation and output it to the screen
What am I doing wrong?

3 Kommentare

YOur A is 1X2 size and B is a vector..so the error.
How do I fix this?
Why are you reusing your variable names for something that appears to be completely unconnected? You create A, B and C as vectors of zeros, then just assign something different to A and attempt to do the same to C except that B is still the original vector, but A has been overwritten.
Use meaningful variable names and this should not happen generally.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Data Exploration finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 2 Nov. 2017

Kommentiert:

am 2 Nov. 2017

Community Treasure Hunt

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

Start Hunting!

Translated by