[X_n,Y_n,Z_n,R_max,Radius,deltaPhi] = Calc_XYZ_Coords_Template(0,10,30,30,1,3595897);
%用脚本调用以上函数
function [X_n,Y_n,Z_n,R_max,Radius,deltaPhi] = Calc_XYZ_Coords_Template(X_min,X_max,NX_pnts,Nphi_pnts,Plot_Geom,Student_ID)
%
% Function which calculates (x,y,z) coordinates of nodes of panels of the body
% Uses Function Get_Body_Radius_Vs_X to get radius corresponding to x vector
% INPUT
% - X_min: Minimum value for the 2D array X_n
% - X_max: Maximum value for the 2D array X_n
% - Nx_pnts: Number of points in x-direction for output arrays
% - Nphi_pnts: Number of points in azimuthal direction for arrays
% - Plot_Geom: Function MUST Plot body geometry if this variable is true
% - Student_ID: Student ID number (without the 搒? to get radius with x
% Use 's' to generate sphere coordinates: useful for testing
% OUTPUT
% - X_n: 2D array with x coordinate of each node.
% - Y_n: 2D array with y coordinate of each node.
% - Z_n: 2D array with z coordinate of each node.
% - R_max: scalar with the maximum value of the body radius
deltaX = (X_max - X_min)/(NX_pnts - 1);
X_n = X_min:deltaX:X_max;
Radius = Get_Body_Radius_Vs_X(X_n,Student_ID); %deltaPhi
%plot(X_n,Radius);
R_max = max(Radius);
deltaPhi = 2 * pi/Nphi_pnts; %deltaPhi
for i = 1:NX_pnts;
for j = 1:Nphi_pnts;
X_n(i,j) = (i-1)*deltaX;
Y_n(i,j) = Radius(i)*sin((j-1)*deltaPhi);
Z_n(i,j) = Radius(i)*cos((j-1)*deltaPhi);
end
end
mesh(X_n,Y_n,Z_n);
%以上是函数代码
捕获.PNG
(92.03 KB, 下载次数: 0)
2018-5-22 14:09 上传
要求生成的图
我生成的图.PNG
(134.62 KB, 下载次数: 0)
2018-5-22 14:10 上传
我生成的1
我生成的图2.PNG
(148.81 KB, 下载次数: 0)
2018-5-22 14:10 上传
我生成的2
2018-5-22 14:13 上传
点击文件名下载附件
1.49 KB, 下载次数: 2
函数
2018-5-22 14:13 上传
点击文件名下载附件
477 Bytes, 下载次数: 2
脚本