Data dimensions must agree error

10 ビュー (過去 30 日間)
Ben Baker
Ben Baker 2017 年 12 月 5 日
回答済み: KSSV 2017 年 12 月 5 日
Hi, I am trying to plot a 3D surface from 4 column data (x,y,z,data). When i run the code to plot the surface using
"surf(x,y,Data')" i got the error "Data dimensions must agree." anyone please help. Thanks. Here is the code :
Axstep=2.5;
Axlines=6000; %number of lines in axial direction
Path = 'C:\Users\asay0001\Google Drive
Data = zeros(480,Axlines);
for i = 1:Axlines
DataTemp = importdata([Path '\DATA (' num2str(i) ').txt']);
Data(:,i) = DataTemp(:,4);
end
Steps = DataTemp(:,1);
Axsteps=[1:Axlines]*Axstep;
figure; plot(Steps,Data(:,[1:Axlines])); grid on;
%need the lateral step size
Latstep=Steps(2)-Steps(1);
[x y] = meshgrid([-99.99:2.5:-497.50],[-400:2.5:97.49]);
surf(x,y,Data')
  2 件のコメント
KSSV
KSSV 2017 年 12 月 5 日
What is size of x,y and Data? They should be matrices of same dimensions......we don't have data in hand to check.
Ben Baker
Ben Baker 2017 年 12 月 5 日
編集済み: Ben Baker 2017 年 12 月 5 日
Axlines=6000, which are number of txt file. in every text file there are 4 columns of x,y,z,data (480(rows) X 4 (column)). Here is below 1 row of one file data out of 6000 files.
x y z data
-99.997000 -400.004000 -2999.998000 0.002255

サインインしてコメントする。

回答 (1 件)

KSSV
KSSV 2017 年 12 月 5 日
That case you have to foolow delaunayTriangulation. Read about it. Check the below code.
N = 100 ;
x = rand(N,1) ;
y = rand(N,1) ;
z = rand(N,1) ;
data = rand(N,1) ;
dt = delaunayTriangulation(x,y,z) ;
tri = dt.ConnectivityList ;
trisurf(tri,x,y,z,data) ;
In the above... x , y, z and data are your column matrices read from the text file.

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by