Hello, how can I calculate the row and column by inserting a 3D matrix using this equation,, so that the input 3D matrix and output 2D matrix
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
clc
clear all
close all
xm= [5 5 5 5;5 -4 -3 -2;5 -1 0 1;5 2 3 4]
n=length(xm);
[cf] =coherence_factor(xm,n)
function [cf] = coherence_factor(xm,n)
for i=1:4;
n=length(xm(i,:));
%%%%%%%%%%%%%%%%%%%% equation %%%%%%%%%%%%%%%%%%%
cf(i)=(abs (sum(xm(i,:))).^2) / (n* sum(abs(xm(i,:).^2)));
end
CF=cf(i);
end
1 comentario
Torsten
el 1 de Mzo. de 2023
Your code works, but it's still not clear what you mean with your question.
Respuestas (1)
DUY Nguyen
el 2 de Mzo. de 2023
Hi, you mean that with your given function, we need to calculate the factor for 3D matrix right?
% Define the input 3D matrix
xm = cat(3, [5 5 5 5;5 -4 -3 -2;5 -1 0 1;5 2 3 4], [4 4 4 4;4 -3 -2 -1;4 0 1 2;4 3 4 5]);
% Get the number of rows and columns in the input matrix
[~,n,~] = size(xm);
% Initialize the output coherence factor matrix
cf = zeros(n, size(xm,3));
% Calculate coherence factor for each slice of the 3D matrix
for i = 1:size(xm, 3)
cf(:,i) = (abs(sum(xm(:,:,i), 2)).^2) ./ (n * sum(abs(xm(:,:,i)).^2, 2));
end
% Display the input and output matrices
disp('Input 3D matrix:')
disp(xm)
disp('Output coherence factor matrix:')
disp(cf)
0 comentarios
Ver también
Categorías
Más información sobre Mathematics and Optimization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!