Hello, how can I calculate the row and column by inserting a 3D matrix using this equation
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Jan
2023-3-1
@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.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!