Hello, how can I calculate the row and column by inserting a 3D matrix using this equation
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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
3 Kommentare
Jan
am 1 Mär. 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.
Antworten (0)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!