필터 지우기
필터 지우기

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

조회 수: 2 (최근 30일)
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
Jan
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개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by