필터 지우기
필터 지우기

How to plot a 2d contour using 3d source of data (measured and recorded within a spreadsheet)

조회 수: 2 (최근 30일)
Hi there,
It would be my greatest pleasure if anyone could assist me with plotting a 2d contour from the attached data (derived from an experiment and stored within a Excel file). It would be so much appreciated if you could do me a favor and include all the MATLAB required scriptting. Thanks!

채택된 답변

Mohammad Dabbagh
Mohammad Dabbagh 2021년 3월 22일
Thank you so much for your quick reply. I truly appreciate it.
I tried this code:
t = readtable('C:\Users\moham\Desktop\Sample.xlsx', 'VariableNamingRule', 'preserve');
N = 50;
x = t{:,1};
y = t{:,2};
irrad = t{:,3};
xvec = linspace(min(x), max(x), N);
yvec = linspace(min(y), max(y), N);
[Xg, Yg] = meshgrid(xvec, yvec);
F = scatteredInterpolant(x, y, irrad);
Ig = F(Xg, Yg);
contourf(Xg, Yg, Ig); colorbar
However, it shows me the following eror:
Error using readtable (line 216)
Invalid parameter name: VariableNamingRule.
  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 3월 22일
t = readtable('C:\Users\moham\Desktop\Sample.xlsx');
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
N = 50;
x = t{:,1};
y = t{:,2};
irrad = t{:,3};
xvec = linspace(min(x), max(x), N);
yvec = linspace(min(y), max(y), N);
[Xg, Yg] = meshgrid(xvec, yvec);
F = scatteredInterpolant(x, y, irrad);
Ig = F(Xg, Yg);
contourf(Xg, Yg, Ig); colorbar

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

추가 답변 (1개)

Walter Roberson
Walter Roberson 2021년 3월 22일
편집: Walter Roberson 2021년 3월 22일
t = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/557822/Sample.xlsx', 'VariableNamingRule', 'preserve');
N = 50;
x = t{:,1};
y = t{:,2};
irrad = t{:,3};
xvec = linspace(min(x), max(x), N);
yvec = linspace(min(y), max(y), N);
[Xg, Yg] = meshgrid(xvec, yvec);
F = scatteredInterpolant(x, y, irrad);
Ig = F(Xg, Yg);
contourf(Xg, Yg, Ig); colorbar

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by