Info

此问题已关闭。 请重新打开它进行编辑或回答。

Hi everyone! I need your help.

4 次查看(过去 30 天)
Engdaw Chane
Engdaw Chane 2018-4-7
关闭: MATLAB Answer Bot 2021-8-20
I have a 3D matrix, X which is 83x92x80. What I need to do is the following:
I tried
% code
%
for n=1:size(X, 3);
for j=3:n;
ss=sum((X (j-1)) .*( X (j-2)) ./ ((n-1) .* (n-2))) ./ 80;
end
end
The result I expect is matrix.
Thank you Chane
  1 个评论
Image Analyst
Image Analyst 2018-4-7
I'm not sure why you're using n as a loop iterator. I see nothing that says n should be a loop iterator. It looks like n should be a constant as far as I can see. It looks like the looping is only over the j variable, not n.
I also don't know what "x sub j" means. Is that the jth element of a vector x? Do you have multiple variables with different names, like x3, x4, x5, x6, ... xn?
And I don't know what the square brackets mean. Do they enclose indexes? Like xj[(j-1)*(j-2)] would be the row of xj that [(j-1)*(j-2)] evaluates to? Or are you taking the array xj (say x3 or x4 or whatever) and multiplying by the scalar [(j-1)*(j-2)] and dividing by the scalar [(n-1)*(n-2)]? It's tough to tell when you're not using standard MATLAB syntax.
So let's say j is 3 and n is 20. Is the sum x20 * [(3-1)*(3-2)] / [(20-1)*(20-2)], which equals x20 * [2*1] / [19*18] which equals x20 * 2/342?

回答(1 个)

KALYAN ACHARJYA
KALYAN ACHARJYA 2018-4-7
%There is no error,
%X=input Matrix
for n=1:size(X, 3);
for j=3:n;
ss=sum((X (j-1)).*( X (j-2))./ ((n-1) .* (n-2)))./ 80;
end
end
  1 个评论
Engdaw Chane
Engdaw Chane 2018-4-7
KALYAN, Thank you. I want the result in a matrix. but here the result is just an element.

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by