0

我有 3 个数组,在一维问题中

A, B, C = arrays (1-100)

一维网格,网格点之间的距离 = a

我需要用 Matlab 代码编写下一个数学表达式:

E = A^(-1/3) * ( D/Dx (B * ((DC/Dx)^(1/3)) )

我把它写成:

DCDx   =  gradient(C, a);
e1     =  B * ( DCDx ^ (1/3) );
e2     =  gradient(e1 , a);
E      =  A^(-1/3) * e2;

编辑 :

for i:length(B)
    DCDx   =  gradient(C, a);
    e1     =  B.* ( Root(DCDx) );
    e2     =  gradient(e1 , a);
    E      =  ( Root(A) )^(-1).* e2;
end

where Root, is my function

function X = Root(X)
X = nthroot(X,3)

unfortunately still is not working. 
error = "Matrix dimensions must agree."

any idea?
4

1 回答 1

1

此代码是否按您的意愿工作?我不明白你在使用循环做什么。

DCDx = gradient(C, a);
e1 = B .* nthroot(DCDx , 3);
e2 = gradient(e1 , a);
E = e2 ./ nthroot(A , 3);

我正在使用以下向量来测试代码:

A=rand(100,1);
B=rand(100,1);
C=rand(100,1);
a=.1;
于 2013-10-29T02:09:41.613 回答