필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Whats wrong with the below equation , I get an error message when i keep this equation in a for loop to run multiple times.

조회 수: 1 (최근 30일)
Expected one output from a curly brace or dot indexing expression, but there were 2 results.
Error in line : I= obj.mhm.S(a)*(abs(obj.mhm.Phi(:,:,a)).^2);

답변 (1개)

Walter Roberson
Walter Roberson 2018년 6월 1일
Either obj or obj.mhm (more likely) are non-scalar structs or objects. non-scalar structs or objects produce multiple outputs when they are indexed further.
Potential correction:
Sa = arrayfun(@(Sarray) Sarray(a), obj.mhm.S);
Phia = arrayfun(@(Phiarray) abs(Phiarray(:,:,a)).^2, obj.mhm.Phi, 'uniform', 0);
I = arrayfun(@(IDX) Phi{IDX} * Sa(IDX), 1:length(Phia), 'uniform', 0);
This would be a cell array of values. It needs to be a cell array because you have multiple obj.mhm and for each one of them you are extracting a 2D array from the Phi field. (Well, you could convert the result to a 3D array instead of a cell array.)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by