Creating Surf plot in MATLAB

조회 수: 2 (최근 30일)
Jonathan Asante
Jonathan Asante 2018년 4월 3일
답변: Walter Roberson 2018년 4월 4일
Would be most grateful if anyone can provide help with creating a surf plot using the comma separated txt file (Attached). I am trying to make the first column x-axis, the second as y-axis and the remaining four columns as the z-values.
  댓글 수: 2
Walter Roberson
Walter Roberson 2018년 4월 3일
편집: Walter Roberson 2018년 4월 4일
Are you wanting four surf plots, are the four values CMYK information, or are the four values RGBA information ?
Jonathan Asante
Jonathan Asante 2018년 4월 3일
Yes I would like four surf plots. And values are CMYK information.

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

답변 (2개)

KSSV
KSSV 2018년 4월 3일
Let your data be in a text file named data.txt
data = importdata('data.txt') ;
x = data(:,1) ;
y = data(:,2) ;
z = data(:,3:end) ;
dt = delaunayTriangulation(x,y) ;
tri = dt.ConnectivityList ;
for i = 1:size(z,2)
trisurf(tri,x,y,z(:,i))
shading interp
colorbar
view(2)
pause(0.5)
end
  댓글 수: 1
Jonathan Asante
Jonathan Asante 2018년 4월 4일
Thanks. Think I didn't express my question well. I am looking for a graph similar to the one attached.

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


Walter Roberson
Walter Roberson 2018년 4월 4일
Then
data = load('CoopStrategyNumGraph.txt');
d11 = reshape(data,11,11,6);
X = d11(:,:,1);
Y = d11(:,:,2);
I_cmyk = d11(:,:,3:6);
inprof = iccread('USSheetfedCoated.icc'); %you need to download this from somewhere
outprof = iccread('sRGB.icc');
C = makecform('icc',inprof,outprof);
I_rgb = applycform(I_cmyk,C);
image(X(1,[1 end]),Y([1 end],1),I_rgb)
title('cmyk to rgb')
figure
subplot(2,2,1)
surf(X, Y, d11(:,:,3));
title('column 3')
subplot(2,2,2)
surf(X, Y, d11(:,:,4));
title('column 4');
subplot(2,2,3)
surf(X, Y, d11(:,:,5));
title('column 5');
subplot(2,2,4)
surf(X, Y, d11(:,:,6));
title('column 6')

Community Treasure Hunt

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

Start Hunting!

Translated by