- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我在使用带有符号函数的 dsolve
时遇到问题。我收到一条错误消息:
"Error using symfun/subsindex (line 121)
Indexing values must be positive integers, logicals or symbolic variables.Error in VK3 (line 9)
[F(n), G(n), H(n)] = dsolve(diff(F) == F2, diff(G) == G2,..."
这是我的代码。这对某些人来说可能看起来很愚蠢,但我对 Matlab 的经验相对较少。如果有人能告诉我哪里出错了,我将不胜感激。
syms F(n) G(n) H(n) F2(n) G2(n)
c = 1.004e-6;
m = input('Angular Velocity = ');
z = 0:1:20;
r = input('Radial Distance = ');
n = z*sqrt(m/c);
[F(n), G(n), H(n)] = dsolve(diff(F) == F2, diff(G) == G2,...
diff(F2) == F^2 - G^2 + F2*H,...
diff(G2) == 2*F + G2*H,...
diff(H) == -2*F,...
F(0) == 0, H(0) == 0, G(0) == 1, F(20) == 0, G(20) == 0);
U = m*r*F(n);
V = m*r*G(n);
W = sqrt(m/v)*H(n);
subplot(3,1,1)
plot(U,n), xlabel('U'), ylabel('z'),...
title('Radial Velocity Component')
subplot(3,1,2)
plot(V,n), xlabel('V'), ylabel('z'),...
title('Azimuthal Velocity Component')
subplot(3,1,3)
plot(W,n), xlabel('W'), ylabel('z'),...
title('Axial Velocity Component')
最佳答案
如错误消息所述,问题在于调用 dsolve
的行.作为文档 indicates , 这个函数要么返回要么
Symbolic array that contains solutions of an equation. The size of a symbolic array corresponds to the number of the solutions.
Structure array that contains solutions of a system of equations. The number of fields in the structure array corresponds to the number of independent variables in a system.
Variables to which the solver assigns the solutions of a system of equations. The number of output variables or symbolic arrays must equal the number of independent variables in a system. The toolbox sorts independent variables alphabetically, and then assigns the solutions for these variables to output variables or symbolic arrays.
换句话说,它不返回符号函数 ( symfun
)。因此,Matlab 将 F(n)
视为数组索引而不是符号函数。我建议使用结构数组形式:
S = dsolve(diff(F) == F2,
diff(G) == G2,...
diff(F2) == F^2 - G^2 + F2*H,...
diff(G2) == 2*F + G2*H,...
diff(H) == -2*F,...
F(0) == 0, H(0) == 0, G(0) == 1, F(20) == 0, G(20) == 0);
但是,您的系统可能没有解析解(您有理由相信它有吗?)因为您会收到警告:
Warning: Explicit solution could not be found.
并且输出 S
将为空。你可以试试 applying assumptions
. (就其值(value)而言,Mathematica 10 并没有更好的表现。)
关于algorithm - 使用 symfun/subsindex 的 MATLAB 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29948003/
我在使用带有符号函数的 dsolve 时遇到问题。我收到一条错误消息: "Error using symfun/subsindex (line 121) Indexing values must be
我尝试了这些命令: im=imread('untitled_test1.jpg'); im1=rgb2gray(im); im1=medfilt2(im1,[15 15]); BW = edge(im
我是一名优秀的程序员,十分优秀!