# how to plot a contour plot with excel data??

조회 수: 23(최근 30일)
sunitha 2021년 3월 31일
댓글: sunitha 2021년 3월 31일
I have to plot a contour plot for excel data. I have two variables x and y , and the individual variables contain 50 data ponts
i defined the data for the variables x and y
contour(x,y) ...i have written code but it is showing the error .can someone tell me where i did mistake ?
##### 댓글 수: 5표시숨기기 이전 댓글 수: 4
sunitha 2021년 3월 31일
should i vary the parameters two at a time and corresponding to that i have to plot this contours ??

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

### 답변(2개)

LO 2021년 3월 31일
편집: LO 2021년 3월 31일
from the folder containing your excel file run
the error about Z may be related to the fact that contour is waiting for a missing variable. But a turnaround is to give to the function an array directly (2D in this case).
%% Import the data
raw = raw(2:end,:);
%% Create output variable
data = reshape([raw{:}],size(raw));
%% Create table
contourgr = table;
%% Allocate imported array to column variable names
contourgr.ksmgcm3 = data(:,1);
contourgr.SmgL = data(:,2);
%% Clear temporary variables
clearvars data raw;
contour(table2array(contourgr));
##### 댓글 수: 0표시숨기기 이전 댓글 수: -1

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

Star Strider 2021년 3월 31일
I cannot see how to do a contour plot of two vectors that do not represent gridded data, since that does not make sense.
However one option could be:
x = D(:,1);
y = D(:,2);
figure
contourf(x*y.')
.

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

### Community Treasure Hunt

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

Start Hunting!