How to draw the contour lines in MATLAB.

조회 수: 2 (최근 30일)
SARVESH R
SARVESH R 2021년 2월 23일
댓글: Walter Roberson 2021년 2월 25일
Can any any one help me how to draw the contour lines in MATLAB. I have data in Excel. i Need to draw contour lines for 0.1, 0.2 till 1.

채택된 답변

Walter Roberson
Walter Roberson 2021년 2월 24일
data = readmatrix('Sai.xlsx');
contour(data, 0.1:0.1:1)
colorbar
  댓글 수: 4
SARVESH R
SARVESH R 2021년 2월 25일
thank you very much sir. its working. sir is it possible to give the lables on the line i am using R2014aversion
Walter Roberson
Walter Roberson 2021년 2월 25일
To label the contours see clabel() https://www.mathworks.com/help/matlab/ref/clabel.html

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

추가 답변 (2개)

Benjamin Kraus
Benjamin Kraus 2021년 2월 23일
The answer depends in part on how the data is formatted in Excel, but something like this should get you started (see attached spreadsheet):
tbl = readtable('Peaks.xlsx');
contour(tbl.Variables,0.1:0.1:1);
  댓글 수: 4
Benjamin Kraus
Benjamin Kraus 2021년 2월 24일
If you replace Peaks.xlsx with Sai.xlsx, my example code seems to work fine on your data.
tbl = readtable('Sai.xlsx');
contour(tbl.Variables,0.1:0.1:1);
If you ran into some issue with that code, could you give more detail? For example, what error messages did you get? Did the picture not look like you expected?
SARVESH R
SARVESH R 2021년 2월 24일
Sir i got an error like this
Warning: Variable names were modified to make them valid MATLAB identifiers.
> In makeValidName at 25
In @table\private\setVarNames at 48
In table.readXLSFile at 113
In table.readFromFile at 35
In readtable at 118
In Contour at 2
Error using table/subsrefDot (line 76)
Unrecognized variable name 'variables'.
Error in table/subsref (line 62)
[varargout{1:nargout}] = subsrefDot(t,s);
Error in Contour (line 6)
contour(tbl.variables,0.1:0.1:1)

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


SARVESH R
SARVESH R 2021년 2월 24일
Sir i would like to draw the contour lines for 0.9, 0.8,0.7, 0.6,0.5,0.4,0.3,0.2 and 0.1

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by