필터 지우기
필터 지우기

I need to create a vector of indices for x and y coordinates and save with assigned value

조회 수: 4 (최근 30일)
I need to create a vector of indices that labels each point, for example point with index 1 that has x and y coordinates x(1), y(1) and save it into a vector such as points_index
x = [1.22, 2.33, 4.56]
y = [5.6, 7.3, 8.2]
points_index = [1 2 3]
any help is much appreciated thank you
  댓글 수: 3
Angela Puccini
Angela Puccini 2021년 8월 27일
I dont think I explained it very well, it should be
I need to create a vector (points_index) that labels each point starting at 1 and going through to n, with coordinates x and y. For point 1 in the points_index would have coordinates x(1), y(1), point 2 would have coordinates x(2), y(2) using Matlab
x = [1.22, 2.33, 4.56]
y = [5.6, 7.3, 8.2]
points_index = [1 2 3]
when I look up point 1 in the command window it should bring up the x and y coordinate
Wan Ji
Wan Ji 2021년 8월 27일
I dont think I catch your idea. What is called 'look up', why not use x(i), y(i) to search the points you want?

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

답변 (1개)

Chunru
Chunru 2021년 8월 27일
x = [1.22, 2.33, 4.56];
y = [5.6, 7.3, 8.2];
for i=1:length(x)
points(i).x = x(i);
points(i).y = y(i);
end
points(2)
ans = struct with fields:
x: 2.3300 y: 7.3000
  댓글 수: 6
Wan Ji
Wan Ji 2021년 8월 27일
I didn't know what the questioner thought, neither did you.
Angela Puccini
Angela Puccini 2021년 8월 27일
my mistake, I am confusing myself!
Thank you both for your help

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

카테고리

Help CenterFile Exchange에서 Time Series Events에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by