Contourf(x,y,z) with imported data

8 visualizaciones (últimos 30 días)
Tove Kopperstad
Tove Kopperstad el 17 de Jun. de 2020
Comentada: Walter Roberson el 18 de Jun. de 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 comentarios
Tove Kopperstad
Tove Kopperstad el 18 de Jun. de 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 el 18 de Jun. de 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)

Iniciar sesión para comentar.

Respuestas (2)

Walter Roberson
Walter Roberson el 18 de Jun. de 2020
You need to use griddedInterpolant() or scatteredInterpolant() on the data, and contourf() the result.
  1 comentario
Tove Kopperstad
Tove Kopperstad el 18 de Jun. de 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

Iniciar sesión para comentar.


darova
darova el 18 de Jun. de 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')

Categorías

Más información sobre Contour Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by