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