フィルターのクリア

3D surface plot help

1 回表示 (過去 30 日間)
Alice Harnden
Alice Harnden 2018 年 3 月 20 日
回答済み: Abraham Boayue 2018 年 3 月 22 日
I am trying to plot a 3d surface of a function vs two variables. Simply, I would like to plot R2 as a function of mu_eff and tau_e with fixed values of the others.
R2=((2/15)*((mu0/(4*pi))^2)*((gamma_H^2)*(mu_eff^2)/(r^6)))*...
((2*(1/((1/tau_r)+(1/tau_e))))+( (13/2)*(1/((1/tau_r)+(1/tau_e)))/(1+(omega_e^2)*((1/((1/tau_r)+(1/tau_e)))^2)))+((3/2)*(1/((1/tau_r)+(1/tau_e)))/(1+(omega_H^2)*((1/((1/tau_r)+(1/tau_e)))^2))))+...
((2/5)*((mu0/(4*pi))^2)*((omega_H^2)*(mu_eff^4)/(((3*k*T)^2)*(r^6)))*((2*tau_r)+(((3/2)*tau_r)/(1+(omega_H^2)*(tau_r^2)))));
The others variables are fixed as
tau_r = 345;
r = 6.6;
B = 3
mu0=4*pi*1e-7; % J/Tesla
r=r*1e-10;
mu_eff=mu_eff*9.274e-24;
tau_r=tau_r*1e-12;
tau_e=tau_e*1e-12;
gamma_H=2.6753e8; % (rad/s)/Tesla
gamma_e=1.760860e11; % (rad/s)/Tesla
k=1.3806503e-23;
T=295;
omega_H=gamma_H*B;
omega_e=gamma_e*B;
I've set mu_eff and tau_e to vary and made a meshgrid
mu_eff = linspace(8,12,100);
tau_e = linspace(0,1,100);
[X, Y] = meshgrid (mu_eff, tau_e);
I believe I then need to replace all the instances of mu_eff and tau_r in the original R2 equation (which I've now called Z) with X. and Y. as
Z=((2/15)*((mu0/(4*pi))^2)*((gamma_H^2)*(X^2)/(r^6)))*...
( (2*(1/((1/tau_r)+(1/Y.))))+( (13/2)*(1/((1/tau_r)+(1/Y.)))/(1+(omega_e^2)*((1/((1/tau_r)+(1/Y.)))^2)) )+((3/2)*(1/((1/tau_r)+(1/Y.)))/(1+(omega_H^2)*((1/((1/tau_r)+(1/Y.)))^2))))+...
( (2/5)*((mu0/(4*pi))^2)*((omega_H^2)*(X.^4)/(((3*k*T)^2)*(r^6)))*( (2*tau_r) + ( ((3/2)*tau_r)/(1+(omega_H^2)*(tau_r^2)) ) ) );
surf(X, Y, Z)
I am just getting bracket errors back in the new Z equation that I cannot seem to fix.
Error: File: test2.m Line: 25 Column: 38 Unbalanced or unexpected parenthesis or bracket.
Sorry if this is a simple question.
Thanks,

回答 (3 件)

Abraham Boayue
Abraham Boayue 2018 年 3 月 21 日
It's difficult to figure out the the exact expression for R2 among those parenthesis. Can you post the equation instead?

Alice Harnden
Alice Harnden 2018 年 3 月 21 日
Sorry, should have done this previously, the code isn't the most user friendly.

Abraham Boayue
Abraham Boayue 2018 年 3 月 22 日
This is what I came up with. I hope this helps.
clear variables
close all
% Define parameters
tau_r = 345e-12;
r = 6.6e-10;
b = 3;
muo = 4*pi*1e-7;
gamma_N = 2.6753e8;
we = b*1.760860e11;
wN = b*2.6753e8;
k = 1.3806503e-23;
T = 295;
% Define constants
C1 = (1/15)*(gamma_N^2/r^6)*(muo/4*pi)^2;
C2 = (1/5*r^6)*(muo/4*pi)^2*(wN/3*k*T)^2;
% Define variables and function
mu_eff = linspace(8,12,200)*9.274e-24;
tau_e = linspace(0,1,200)*1e-12;
[x,y] = meshgrid(mu_eff,tau_e);
tau_c = 1./(1/r +1./y);
A = (13*tau_c)./(1+(we*tau_c).^2);
B = (3*tau_c)./(1+(wN*tau_c).^2);
C = (3*tau_r)/(1+(wN.*tau_r)^2);
R2 = C1*(x.^2).*(4*tau_c + A + B )+ C2*(x.^4).*(4*tau_r + C);
surf(x,y,R2)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by