Effacer les filtres
Effacer les filtres

Hello, how can I calculate the row and column by inserting a 3D matrix using this equation

2 vues (au cours des 30 derniers jours)
clc
clear all
close all
xm= [5 5 5 5;5 -4 -3 -2;5 -1 0 1;5 2 3 4]
xm = 4×4
5 5 5 5 5 -4 -3 -2 5 -1 0 1 5 2 3 4
n=length(xm);
[cf] =coherence_factor(xm,n)
cf = 1×4
1.0000 0.0741 0.2315 0.9074
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
  3 commentaires
hisham mohammed
hisham mohammed le 1 Mar 2023
I want to add another forloop to calculate 3D matrix of CF
Jan
Jan le 1 Mar 2023
@hisham mohammed: You define n as input argument, but overwrite it by the same value in each iteration. Of course all xm(i,:) have the same length. So use this before the loop:
m = size(xm, 2);
The line CF=cf(i); is useless, because CF is not replied. Currently the output is a vector. It is not clear how you want to expand ot to 3D.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by