Contourf(x,y,z) with imported data
11 views (last 30 days)
Show older comments
I have a set of data I would like to make a contour plot of, for some reason I keep getting theese errors:
Error using contourf (line 57)
The size of X must match the size of Z or the number of columns
of Z.
Error in WIIP (line 5)
contourf(x,y,z)
I have tried with and without transposing z and switching x and y around. Still not working. Each of the variables is calling the data correctly, so I dont know what the issue is.
Code:
num = xlsread('WSS Data.xlsx','Normal','B2:E46');
x = num(:,2:4);
y = num(2:45,:);
z = num(2:45, 2:4);
contourf(x,y,z)
The spot (1,1) is blank, but that shouldnt be an issue from what I can tell.
3 Comments
Walter Roberson
on 18 Jun 2020
num = xlsread('WSS Data.xlsx','Normal','B2:E46');
x = num(1,2:end);
y = num(2:end,1);
z = num(2:end, 2:end);
contourf(x,y,z)
Answers (2)
Walter Roberson
on 18 Jun 2020
You need to use griddedInterpolant() or scatteredInterpolant() on the data, and contourf() the result.
darova
on 18 Jun 2020
You are import data in a wrong way. Try this
num = xlsread('WSS Data.xlsx','Normal','C:E');
x = num(:,1);
y = num(:,2);
z = num(:,3);
plot3(x,y,z,'.-r')

0 Comments
See Also
Categories
Find more on Contour Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!