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 件のコメント

DanTheMan
DanTheMan 2015 年 7 月 28 日
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

サインインしてコメントする。

回答 (2 件)

Cedric
Cedric 2015 年 7 月 29 日
編集済み: Cedric 2015 年 7 月 29 日
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.

カテゴリ

ヘルプ センター および File ExchangeSurfaces, Volumes, and Polygons についてさらに検索

質問済み:

2015 年 7 月 28 日

編集済み:

2015 年 7 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by