Error Using fprintf Invalid file identifier. Use fopen to generate a valid file identifier.

1 次查看(过去 30 天)
Hello,
I have this script.
I = (kron(ev1_of_alice,(ev1_of_bob+ev2_of_bob)))+kron(ev2_of_alice,(ev1_of_bob-ev2_of_bob));
if ~isnan(I)
fprintf("I = "+ I + "\n");
if abs(I)>2
fprintf("Violated Bell Inequality");
end
else
fprintf("Not enough data to determine S\n")
end
And when I run the script I have this error:
Error Using fprintf Invalid file identifier. Use fopen to generate a valid file identifier.
But I dont understand anything I is not a file I am trying to write a value not a file. How can I solve it?

采纳的回答

the cyclist
the cyclist 2020-6-21
Is this good enough?
I = rand(2);
if ~isnan(I)
I
if abs(I)>2
fprintf("Violated Bell Inequality");
end
else
fprintf("Not enough data to determine S\n")
end

更多回答(1 个)

madhan ravi
madhan ravi 2020-6-21
"I = "+ I + "\n" % without fprintf(...)
  3 个评论

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by