Output format error?

Hi There, I'm trying to output data to screen in two columns, the first column contains the ginputs (x,y coordinates) from user point selections using the mouse, whilst the second column is a set of reference coordinates held in the string "ActualValues".
I've only got 3 ginput (x,y) values in contrast to 10 reference values as I'm still getting the code functional.
I know this is a very basic problem, but I'm stuck fast and would really appreciate some help!
I keep getting the following error: Error using vertcat Dimensions of matrices being concatenated are not consistent. FinalOutput = [A, ActualValues; B; C];
This is my 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);
ActualValues = [124 93 109 77 125 83 117 75 122 80];
uiwait(msgbox('Choose Point A'));
[x,y] = ginput(1);
hline = plot(x,y,'r+', 'MarkerSize', 50);
A = [x, y];
uiwait(msgbox('Choose Point B'));
delete(hline);
[x,y] = ginput(1);
hline1 = plot(x,y,'r+', 'MarkerSize', 50);
B = [x, y];
uiwait(msgbox('Choose Point C'));
delete(hline1);
[x,y] = ginput(1);
hline2 = plot(x,y,'r+', 'MarkerSize', 50);
C = [x, y];
%Display Values:
disp ( 'User Values: Actual Values: Error:')
%FinalOutput = [A, B, C]; Formats output
%disp(FinalOutput); Displays previous formatted output (outputs FinalOutput)
FinalOutput = [A, ActualValues; B; C];
disp(FinalOutput);
disp(A);
disp(B);
disp(C);
How do I Fix this?
Many thanks.

2 Comments

ActualValues = [124 93 109 77 125 83 117 75 122 80];
this should be a matrix with..it shall have both x and y coordinates.
DocD
DocD on 3 Nov 2017
Edited: DocD on 3 Nov 2017
I've tried that it still doesn't work, originally it was: ActualValues = [124 93; 109 77; 125 83; 117 75; 122 80];
its something to do with how its referenced in "finalOutput" at the bottom, but I don't know what or indeed how to correct, please help!
FinalOutput = [A, ActualValues; B; C]; disp(FinalOutput);

Sign in to comment.

Answers (1)

KSSV
KSSV on 3 Nov 2017
USe this:
FinalOutput = [A; ActualValues; B; C]
with ActualValues as [124 93; 109 77; 125 83; 117 75; 122 80];

3 Comments

DocD
DocD on 3 Nov 2017
Edited: DocD on 3 Nov 2017
For some reason that gives me:
FinalOutput =
205.1477 224.4505
124.0000 93.0000
109.0000 77.0000
125.0000 83.0000
117.0000 75.0000
122.0000 80.0000
409.0457 159.9828
677.4115 179.4730
205.1477 224.4505
124.0000 93.0000
109.0000 77.0000
125.0000 83.0000
117.0000 75.0000
122.0000 80.0000
409.0457 159.9828
677.4115 179.4730
How would you get the first, 7th and 8th value in one column and the rest in an adjacent column? I'm not sure why it's repeating it twice either!
Is there a way to get them side by side?
A= [2, 3]
B= [4, 7]
C= [1, 8]
D= [1 1; 2 2; 3 3; 4 4; 5 5; 6 6; 7 7]
FinalOutput = [A; D; B; C]
is it repeating?
DocD
DocD on 3 Nov 2017
I'm sorry, I didn't get a response, so I posted out a wider question!
Looks Like I'm repeating myself too!
The amendment to the code you provided repeats as you can see above, I'd like the first, 7th and 8th x, y coords in the first column and the other values in the column next to it.
I appreciate your help!

Sign in to comment.

Categories

Asked:

on 3 Nov 2017

Commented:

on 3 Nov 2017

Community Treasure Hunt

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

Start Hunting!