MATLAB: How to create a surface plot with 3 independent variables? I dont want to construct using a trisurface plot. File is attached.

meshmeshgridsurf

I would like to construct a 3D (surface plot) to show graphical representation of mode shape. X and Y denote the scan point and magnitude represents the displacement at that point. For example magnitude1 (m1) represents the displacement at point (x1,y1). Please advise.

Best Answer

Your data are gridded, so you simply need to reshape the vectors appropriately, then plot the resulting matrices:
fidi = fopen('fastscan 118hz 1g.txt','rt');
Dc = textscan(fidi, '%f%f%f', 'HeaderLines',11, 'CollectOutput',1);
fclose(fidi);
D = cell2mat(Dc);
[~,frames] = unique(D(:,2)); % Indices Of Repeat Values
mdf = mean(diff(frames)); % Frame Length
Xr = reshape(D(:,1), mdf, []); % Reshape ‘X’
Yr = reshape(D(:,2), mdf, []); % Reshape ‘Y’
Mr = reshape(D(:,3), mdf, []); % Reshape ‘Magnitude’
figure
surfc(Xr, Yr, Mr)
grid on
view(105, 15)
xlabel('X')
ylabel('Y')
zlabel('Magnitude (m)')
producing: