I'm trying to make a contour map but I keep running into a small issue. Does anyone know what I have to do to either my function file or script file?

function [V] =TPF(P,r,z)
%UNTITLED6 Summary of this function goes here
j=length(r);
n=length(z);
VS=zeros(j,n);
for i=1:j
for k=1:n
VS(i,k)=((3*P)./(2*pi*z(k).^2)).*1./((r(i)./z(k)).^2+1).^(5/2);
end
end
end
----------------------------------------------------------------
clear all
close all
r=(-1:0.1:1);
z=(0.5:0.1:2);
P=1000;
[R,Z]=meshgrid(r,z);
[V]=TPF(P,R,Z);
figure(1)
cs=contour(R,Z,V);
clabel(cs);
figure(2)
cs=contourf(r,z,V);
colorbar
figure(3)
surfc(r,z,V)

1 comentario

I keep getting an error that says: The size of X must match the size of Z or the number of columns
Error in line 15

Iniciar sesión para comentar.

Respuestas (2)

Cedric
Cedric el 29 de Jul. de 2015
Editada: Cedric el 29 de Jul. de 2015
Your function doesn't define it's output argument V, but another variable VS.
You should change the double FOR loop for a vector approach if you can.
PS: it seems that you can replace the whole function call with
V = 3*P./(2*pi*Z.^2) .* 1./((R./Z).^2+1).^(5/2) ;
which is the vector approach mentioned above. Just check that it works.

Categorías

Más información sobre Contour Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Jul. de 2015

Editada:

el 29 de Jul. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by