如何找出MATLAB版本2016b中的符号错误

问题描述 投票:-2回答:2

我尝试了如下所示的代码,它与装有Matlab 2017a版本的朋友PC完美配合。我也有相同版本的Matlab。每当我尝试在PC上编码时,都会显示错误:syms not defined

 clear all
 close all
 clc
 % here py = py/p0 and px = px/p0 and e = np0
 % g = 0.01; 
 a = 4*pi/3;
 %g = 0.15;
 %a = 8*pi/5;
 g = [0 0.01 0.1 0.75];
 %n = -0.1:0.1:0.1;
 syms px py

 C = sqrt((px-1)^2 + py^2 - n.^2);   
 K = sqrt((px+1)^2 + py^2 - n.^2);

 y = sqrt(1-g).*(n.*(C - K) +2*px*py ) + sin(a).*(K*(px-1) + C*(px + 1)) -cos(a).*(2*n.*px + (C - K)*py);
 %sols = solve(y == 0,px)
 fimplicit(y) % it gives the perfect plots in Matlab R2017b but i have R2016a then how i can plot with Matlab R2016a
 axis([-3 3 -1 15])

任何人都可以弄清楚,此问题的原因是什么?。

matlab matlab-figure
2个回答
1
投票

使用ezplot可能就是您想要的。对于n的一个值和g的一个值,您可以执行以下操作:

clear all
close all
clc
%% Fermi arc formation with Energy not equal to zero.
% here py = py/p0 and px = px/p0 and e = np0
% g = 0.01; 
a = 4*pi/3;
%g = 0.15;
%a = 8*pi/5;
g = 0.01;
n = 0.1;
syms px py

C = sqrt((px-1)^2 + py^2 - n.^2);   % here i have just replaced hC by C
K = sqrt((px+1)^2 + py^2 - n.^2);   % here i have just replaced hK by K

y =  sqrt(1-g).*(n.*(C - K) +2*px*py ) + sin(a).*(K*(px-1) + C*(px + 1)) -    cos(a).*(2*n.*px + (C - K)*py);
%sols = solve(y == 0,px)
ezplot(y) % it gives the perfect plots in Matlab R2017b but i have R2016a then how i can plot with Matlab R2016a
axis([-3 3 -1 15])

0
投票

[现在,我发现没有安装符号功能的工具箱,在重新安装Matlab和符号工具箱后进行了尝试,得到了理想的图。

现在我已经为g的4个不同值绘制了上面的代码

g = 0, 0.05, 0.15, 0.2; % in image g represented as gamma
a = 8pi/5; % in image a = alpha

Plot of above code

© www.soinside.com 2019 - 2024. All rights reserved.