Using variables from .mat structures.
조회 수: 2 (최근 30일)
이전 댓글 표시
there are given 2 channel matrices, namely,
channel_1.mat and channel_2.mat which contain the struct data.
I need to use variables from this struct in folowing function:
But I don't know how I can implement this
%Import channel information
data=load('C:\Users\askrrow\Downloads\MSCSP_MoCo_2023SoSe_HW5\channel_1.mat')
data=load('C:\Users\askrrow\Downloads\MSCSP_MoCo_2023SoSe_HW5\channel_2.mat')
%Full correlation matrices estimation
Nt=length(data.nF);
for i=nF:Nt
f(Nt,nT,nF(i))
end
function Rh = f(Nt,nT,nF)
Rh=1/Nt.*sum(reshape(data.H(:,:,nT,nF),[],1).*reshape(data.H'(:,:,nT,nF),[],1),'all')
end
답변 (1개)
Sanjana
2023년 6월 5일
Hi,
The error message you encountered is due to attempting to access the transpose of the matrix H through parentheses directly. In MATLAB, the parentheses “()” operator has higher precedence than the transpose operator “'” according to the Operator Precedence Rules. Therefore, the expression “data.H'(:,:,nT,nF)” is interpreted as applying the parentheses to the transpose operator itself, rather than to the transposed matrix “ data.H'” resulting in an error.
To resolve this issue, it is recommended to assign the transposed matrix to a new variable before accessing its columns. By doing so, you explicitly indicate the desired order of operations.
Please, refer to the following link to know more about operator precedence rules,
For further clarification on accessing variables stored in a .mat file and accessing variables stored in a structure array, you can refer to the following links:
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Structures에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!