How to implement mathematical functions
1 次查看(过去 30 天)
显示 更早的评论
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283863/image.jpeg)
I want to implement above mathematical functions, how can do this???
2 个评论
John D'Errico
2020-4-12
编辑:John D'Errico
2020-4-12
Yours is the kind of question that almost never gets a satisfactory answer on a forum. Why not? Its kind of a vague question, where it seems clear the asker does not really understand MATLAB that well. To a large extent, the answer needs to be to learn to use MATLAB.
We don't know what you have in the form of a function for nu. We don't know what your data looks like, and in what form it is stored. Sadly, we know absolutely nothing about what YOU know about MATLAB, partially because we see no effort made by you to try to solve your problem. When I see a fragment of MATLAB code written by someone, I can then judge their relative level of skill and knowledge about MATLAB. When I see no code at all, then I must assume this is a complete novice asking the question.
It would help if you gave a very clear, limited example, where we see in what form your data is stored, and where we see the answer you would have expected from that sample problem.
So what happens is nobody really knows what you are asking, but they can expect to enter into that conversation means someone would need to enter into a rather lengthy dialogue where they figure out what you have, and then try to teach you enough MATLAB to solve the problem. In the end, most people just glance at your question and then move on. So questions like this one tend to die unanswered, or they get approximate answers where people try to guess what you have.
回答(2 个)
Ameer Hamza
2020-4-12
编辑:Ameer Hamza
2020-4-12
For first equation
V % your 3D matrix
V_mean = mean(v, 1:ndims(V))
v = sum((V-V_mean).^2, 1:ndims(V))
The second equation
V % your 3D matrix
s = -sum(V.^2.*log(1+V.^2), 1:ndims(V))
Thiago Henrique Gomes Lobato
2020-4-12
Considering that nu is a function of x,y,z and you described it as a 3-dimensional matrix in your code you could implement then as follows:
nu = rand(10,10,10); % substitute by your nu
F1 = sum( (nu(:)-mean(nu(:))).^2);
F2 = -sum( ( nu(:).^2.*log(1+nu(:).^2)));
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!