Creating a simple 2D contour plot from XYZ values from an excel table that I imported into Matlab

Hello everyone, As mentioned in the heading - I'm having trouble using data in an excel table that I imported into Matlab to then plot up a visual 2D contours plan using that data (XYZ data) The main problem I am having is... "Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported. Use a row subscript and a variable subscript."
Data is attached
Any help greatly appreciated :)

4 Comments

The main problem I am having is ...
It's difficult to tell you what you're doing wrong if you don't tell us what you're doing.
In any case, it's really not clear what 2D contour you're hoping to obtain from your 3D data. There's not many point and they're scattered all over. No two point is at the same height (Z) so all the contours would be made of just one point.
sorry I didn't explain properly. I mean 2D as in just a plan view of the contours. XY being the coords and Z being the height. I didn't realise the heights had to be round figures or have ones matching up the same so they know where to join... The problem is underneath in "" i.e It's telling me to use a row subscript and a variable subscript
The problem is underneath in "" i.e It's telling me to use a row subscript and a variable subscript
Yes, you've told us the error you're getting but not what you're doing to get that error
Actually that's a good point. I was using this below code which another helpful member of the forum mentioned for a similar question...But really I have no idea what I'm doing...
[Num,Txt,Raw]=xlsread('contours.xls');
x=Num(:,1);
y=Num(:,2);
z=Num(:,3);
F = TriScatteredInterp(x,y,z)
[qx qy] = meshgrid(min(x):0.01:max(x),min(y):0.01:max(y))
qz = F(qx,qy);
contour(qx,qy,qz)

Sign in to comment.

 Accepted Answer

Thanks all. I managed to achieve a satisfactory result using TeraPlot

More Answers (1)

You can first convert the table into an array. For example
data = readtable('Contours.xls');
dataArray = table2array(data);
contourf(dataArray);

Categories

Products

Release

R2018a

Tags

Asked:

on 25 May 2018

Edited:

T K
on 1 Dec 2022

Community Treasure Hunt

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

Start Hunting!