3次元グラフの作成

8 views (last 30 days)
N/A
N/A on 9 Jun 2018
Answered: N/A on 12 Jun 2018
下記に示すようなプログラムを書き、x軸がx、y軸がy、z軸がQ1の3次元グラフを作成しようとしましたが、「エラー: surf (line 82) Z はスカラーでもベクトルでもなく、行列でなければなりません。エラー: sample (line 73)surf(e1,e2,Q1,'.');」というような内容のエラーが表示されました。どのように修正すれば、3次元グラフを作成できますか? Q1を求める計算式は正しいものとします。
A=19.6*10^-6;%受光面積
n=1.49;%屈折率
k=deg2rad(62.5);%LEDの半値角
m=-log(2)/log(cos(k));
Pt=0.764;%TXパワー
R=0.24;%受光感度
kb=1.38*10^(-23);%ボルツマン定数
T=300;%絶対温度
F=1;%雑音指数
BR=10*10^6;%RXの帯域幅
RL=510;%フィードバック抵抗
q=1.602*10^(-19);%電子電荷
Id=120*10^(-12);%暗電流
I0=0;%スペース時の電流
wx=5;
wy=5;
fov=25;
H=1.5;
oR=50;%フォトダイオードのなす角度
OR=deg2rad(oR);
t=deg2rad(0);%TXの傾き角
j=1;
for x=0:0.1:wx
for y=0:0.1:wy
e1(j)=x;
e2(j)=y;
H1=sqrt((wx/2-x)^2+y^2+H^2);%TX1とRXユニット間の距離
cost11=H/H1;%cos(ΦT)
t11=acos(cost11);%ΦT
rad2t11=rad2deg(t11);
cosr11=(y*sin(OR)+H*cos(OR))/H1;%cos(ΦR)
r11=acos(cosr11);%ΦR
rad2r11=rad2deg(r11);%ラジアンを度に変換する
if rad2r11<=fov
h11=((m+1)*A*(cost11^m)*(n^2)*cosr11)/(sin(deg2rad(fov))*sin(deg2rad(fov))*2*3.14*power(H1,2));
P11=Pt*h11;
elseif rad2r11>fov
h11=0;
P11=Pt*h11;
end
cosr12=((wx/2-x)*sin(OR)+H*cos(OR))/H1;%cos(ΦR)
r12=acos(cosr12);%ΦR
rad2r12=rad2deg(r12);%ラジアンを度に変換する
if rad2r12<=fov
h12=((m+1)*A*(cost11^m)*(n^2)*cosr12)/(sin(deg2rad(fov))*sin(deg2rad(fov))*2*3.14*power(H1,2));
P12=Pt*h12;
elseif rad2r12>fov
h12=0;
P12=Pt*h12;
end
P1=P11+P12;
I1=R*P1;
N1=(4*kb*T*F*BR)/RL+2*q*(I1+Id)*BR;
N0=(4*kb*T*F*BR)/RL+2*q*Id*BR;
Q1(j)=(I1-I0)/(sqrt(N1)+sqrt(N0));
BER1=0.5*erfc(Q1/sqrt(2));
j=j+1;
end
end
surf(e1,e2,Q1);

Accepted Answer

Naoya
Naoya on 12 Jun 2018
X,Y,Z 共に ベクトルとして与えられたデータから3次元プロットを描画される場合ですが、下記記事が参考いただけます。
https://www.mathworks.com/matlabcentral/answers/96808-excel-xyz-3
記事を元に、頂いたプログラムにあてはめてみますと、下記のようなコードで 3次元プロットが確認できます。
%surf(e1,e2,Q1);
e1_lin = linspace(min(e1),max(e1),51);
e2_lin = linspace(min(e2),max(e2),51);
[E1,E2]=meshgrid(e1_lin,e2_lin);
Q1_mesh = griddata(e1,e2,Q1,E1,E2);
surf(E1,E2,Q1_mesh)

More Answers (1)

N/A
N/A on 12 Jun 2018
ありがとうございました。記事を参考にプログラムを修正してみます。

Categories

Find more on 2 次元および 3 次元プロット in Help Center and File Exchange

Products


Release

R2017a

Community Treasure Hunt

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

Start Hunting!