필터 지우기
필터 지우기

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