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

1 view (last 30 days)
Mohammad Dabbagh on 22 Mar 2021
Commented: Walter Roberson on 22 Mar 2021
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 on 22 Mar 2021
Thank you so much for your quick reply. I truly appreciate it.
I tried this code:
N = 50;
x = t{:,1};
y = t{:,2};
xvec = linspace(min(x), max(x), N);
yvec = linspace(min(y), max(y), N);
[Xg, Yg] = meshgrid(xvec, yvec);
Ig = F(Xg, Yg);
contourf(Xg, Yg, Ig); colorbar
However, it shows me the following eror:
Invalid parameter name: VariableNamingRule.
Walter Roberson on 22 Mar 2021
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};
xvec = linspace(min(x), max(x), N);
yvec = linspace(min(y), max(y), N);
[Xg, Yg] = meshgrid(xvec, yvec);
Ig = F(Xg, Yg);
contourf(Xg, Yg, Ig); colorbar

Walter Roberson on 22 Mar 2021
Edited: Walter Roberson on 22 Mar 2021
N = 50;
x = t{:,1};
y = t{:,2};
xvec = linspace(min(x), max(x), N);
yvec = linspace(min(y), max(y), N);
[Xg, Yg] = meshgrid(xvec, yvec);
Ig = F(Xg, Yg);
contourf(Xg, Yg, Ig); colorbar