Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

Hi everyone! I need your help.

2 vues (au cours des 30 derniers jours)
Engdaw Chane
Engdaw Chane le 7 Avr 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
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 commentaire
Image Analyst
Image Analyst le 7 Avr 2018
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?

Réponses (1)

KALYAN ACHARJYA
KALYAN ACHARJYA le 7 Avr 2018
%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 commentaire
Engdaw Chane
Engdaw Chane le 7 Avr 2018
KALYAN, Thank you. I want the result in a matrix. but here the result is just an element.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by