Contourf(x,y,z) with imported data

11 views (last 30 days)
Tove Kopperstad
Tove Kopperstad on 17 Jun 2020
Commented: Walter Roberson on 18 Jun 2020
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
Tove Kopperstad
Tove Kopperstad on 18 Jun 2020
This is my data attached, y is location, x is a relative propeller speed and z is relative air velocity.
The blank spot isnt in x, y, or z, its just imported in along from the excel file.
I would like for the contour plot to show how the air velocity changes along the location variable with respect to the 3 different relative propeller speeds.
Walter Roberson
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)

Sign in to comment.

Answers (2)

Walter Roberson
Walter Roberson on 18 Jun 2020
You need to use griddedInterpolant() or scatteredInterpolant() on the data, and contourf() the result.
  1 Comment
Tove Kopperstad
Tove Kopperstad on 18 Jun 2020
This doesnt seem to be working, looks all three of the variables would have to be vectors from what I read and tested. One of my variables is a matrix. ie X=1x3 Y=44x1 and Z=44x3

Sign in to comment.


darova
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')

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!