How do I stitch these data and get a final plot

조회 수: 3 (최근 30일)
Ankita
Ankita 2024년 5월 27일
댓글: Mathieu NOE 2024년 7월 9일
this is my code
I want to take all the 61*6 X data(1st, 4th,7th...columns) , all 61*6 Y data (2nd, 5th,8th...colums) and all 61*6 Z data(3rd,6th,9th ...columns) stitch all of them and get the final surface plot of X, Y, Z. How do I do this? Can anybody please help sooner.
  댓글 수: 1
Rik
Rik 2024년 5월 27일
Please post your code here and attach your data in a mat file. Your text sounds like you have some array with 61 rows and 18 columns. This should be possible in one line of code. What did you try?

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

답변 (1개)

Mathieu NOE
Mathieu NOE 2024년 5월 27일
hello
maybe this ?
clear all
S=readmatrix ('Probe.txt');
T=S(:,[2,3]);
i=0;
for j=0:60:300
R=[cos(j) -sin(j);sin(j) cos(j)]; %rotation matrix
a(:,i+1:i+2)=T*R; %stores value of each x and y in separate columns for every iteration
%disp(a);
i=i+2;
end
D=readmatrix ('selfmeas.txt');%load the whole 2DP file
A=D(82:447,:); %extract only the z data
j=1;
for i=1:366
if (i==j)
P(i,1)=A(j,4);
j=j+61;
else
P(i,1)=A(i,2);
end
end
z=reshape(P,[61,6]); %reshape each clocking data into separate columns
disp(z);
C = [a(:,1:2) z(:,1) a(:,3:4) z(:,2) a(:,5:6) z(:,3) a(:,7:8) z(:,4) a(:,9:10) z(:,5) a(:,11:12) z(:,6)];
disp(C);
% I want to take all the 61*6 X data(1st, 4th,7th...columns) , all 61*6 Y data (2nd, 5th,8th...colums)
% and all 61*6 Z data(3rd,6th,9th ...columns) stitch all of them and get the final surface plot of X, Y, Z.
x = C(:,1:3:end);
y = C(:,2:3:end);
z = C(:,3:3:end);
x = x(:);
y = y(:);
z = z(:);
%%%%%%
I = scatteredInterpolant(x,y,z,'linear','none');
N = 100;
x = linspace(min(x),max(x),N);
y = linspace(min(y),max(y),N);
[x,y] = meshgrid(x,y);
z = I(x,y);
surf(x,y,z);
colorbar('vert')

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by