필터 지우기
필터 지우기

Print an array of coordinates with 2 Arrays of Varriables.

조회 수: 4 (최근 30일)
I have two Arrays of multiple numbers lets call it X and Y. I Need to make another array of numbers displayed as cordinates. So let's say that X[150 200 300 500] and Y[300 500 800 300] I need an array like [150,300 200,500 300,800 500,300]. the purpose is then to copy the data and paste to Autacad to make a polyline. Is there a simple way to do this ? I appriciate any kind of help.

채택된 답변

Michael
Michael 2021년 6월 2일
Simple in Matlab
X = [150 200 300 500]';
Y = [300 500 800 300]';
coords = [X,Y]
coords =
150 300
200 500
300 800
500 300
  댓글 수: 6
Michael
Michael 2021년 6월 2일
Add a new line character and use the fprintf command:
X = [150 200 300 500]';
Y = [300 500 800 300]';
thematrix = [X,Y]';
asvector = thematrix(:);
stringvector = num2str(asvector);
comma_vector = repmat(',\',1,numel(X))';
return_vector = repmat(' n',1,numel(X))';
blah = [stringvector,comma_vector,return_vector]';
%XY = ['[',blah(1:end-1),']']
fprintf(blah(:)')
Produces this in the command window:
150, 300
200, 500
300, 800
500, 300
Please remember to accept this answer.
Þorfinnur Karl Magnússon
Þorfinnur Karl Magnússon 2021년 6월 2일
Thank you for the help sir I greatly appriciate it :D

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by