フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Why is 0 not valid in mean fucntion?

1 回表示 (過去 30 日間)
Gözde Üstün
Gözde Üstün 2020 年 6 月 21 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello,
I have this function:
function [coin, I,evAlice,evBob] = CH_(sigma_x,sigma_z)
ev1_of_alice = sigma_x;
ev2_of_alice = sigma_z;
ev1_of_bob = sigma_x+sigma_z;
ev2_of_bob = sigma_x-sigma_z;
S = + mean(coin(ev1_of_alice,ev1_of_bob)) ...
- mean(coin(ev1_of_alice,ev2_of_bob)) ...
+ mean(coin(ev2_of_alice,ev1_of_bob)) ...
+ mean(coin(ev2_of_alice,ev2_of_bob));
if ~isnan(S)
fprintf("S = " + S + "\n");
if abs(S) > 2
fprintf("V! (|S|>2)\n")
end
else
fprintf("Not enough data to determine S\n")
But when coin has "0" value like that coin (1,0) or (0,1) I have this error:
Index in position 1(2) is invalid. Array indices must be positive integers or logical values.
why I am getting that how can I fixed it?
  3 件のコメント
the cyclist
the cyclist 2020 年 6 月 21 日
Oh, also, this is confusing, because you output coin like a variable, but you also are calling it as a function (it seems). I think you might have a more fundamental problem with the code.
Devineni Aslesha
Devineni Aslesha 2020 年 6 月 24 日
I am assuming that the coin is other nested function defined in CH_. function. Using the same name for variable and nested function is not supported in nested functions. Refer this link for more information.
But it seems that the coin is considered as an array from the above error. It would be helpful if you provide the entire code and give an example of calling CH_ function to replicate the error.

回答 (0 件)

この質問は閉じられています。

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by