필터 지우기
필터 지우기

How can I increase the the number of data-points in a scattered data set?

조회 수: 79 (최근 30일)
I have a 461 by 3 matrix in which the first column is x coordinates, second one y and third one z coordinates. The values of the elements of z column is o. (i.e it is actually 2D data but I need 3D data for further calculation so I kept the third column.). The values of the data set are scattered values.
Now I want to get more coordinate values (x,y,z) within this data set. The z values will be zero.
Can I use the function interp1/2/3??? how??
My main problem is achieving the coordinate matrix with all (prev.+interpolated) values. The interp function shows the value of a desired point, but I do not need that.
Thanks in advance.

채택된 답변

David Sanchez
David Sanchez 2013년 7월 8일
M=rand(50,3);
M(:,3) = 0;
M = sort(M,1,'ascend');
% double the data in X column
x_extended = interp(M(:,1),2);
% dobule the data in Y column
y_extended = interp(M(:,2),2);
% new data containing all data
M_new = [x_extended, y_extended, zeros(100,1)];

추가 답변 (3개)

Kheya Banerjee
Kheya Banerjee 2013년 7월 8일
David, thank you very much. It woks perfectly! (as far as the data set is long enough)

Kheya Banerjee
Kheya Banerjee 2013년 7월 8일
David, there is a small problem. as I am considering the data as coordinates, (x,y), the actual data points become changed when you sorted it, isn't it right??
is there any way to keep the data combinations same???? i.e. x point and y point of a particular row (of the given data sheet) remains in the same row after interpolating,too.
Can you help me in this matter?

David Sanchez
David Sanchez 2013년 7월 8일
Just skip the sort command, I did it for testing purposes. The interp will create new point in between every consecutive pair of data:
M = my_50x3_data_matrix;
x_extended = interp(M(:,1),2);
% dobule the data in Y column
y_extended = interp(M(:,2),2);
% new data containing all data
M_new = [x_extended, y_extended, zeros(100,1)];
  댓글 수: 1
Shins K
Shins K 2022년 7월 2일
When I used the same code, I am getting the error message "Unrecognized function or variable 'interp'". Could you please let me know why it is so, if you know?

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

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by