Filter löschen
Filter löschen

Matlab cannot produce result

1 Ansicht (letzte 30 Tage)
vokoyo
vokoyo am 4 Mai 2018
Bearbeitet: vokoyo am 5 Mai 2018
.
function Y = myFunction(d,n,theta)
Y = coinflip(100,100,0.25);
d = 100;
n = 100;
theta = 0.25;
Y = [ ];
for Dloop = 1:d
for Nloop = 1:n
X =randn(1);
Y = [Y;X];
end
end
Y(Y<theta) = 0;
Y(Y>theta) = 1;
histogram(Y)
(I get some errors as below -)
function Y = myFunction(d,n,theta)
Error: Function definition not supported in this context.
Create functions in code file.
(another error is as below)
Error in myFunction (line 2)
Y = coinflip(100,100,0.25);
(other error is as below)
Y = coinflip(100,100,0.25);
Undefined function or variable 'coinflip'.
.
Here please help me to modify the errors and able to produce one correct output graph
.
  15 Kommentare
vokoyo
vokoyo am 5 Mai 2018
Bearbeitet: vokoyo am 5 Mai 2018
Sorry I cannot understand
Can you please show all the detail information
I would like to compare it to the two graphs (in attached file Question 2)
vokoyo
vokoyo am 5 Mai 2018
Bearbeitet: vokoyo am 5 Mai 2018
Matlab Programming - I am not sure how to modify it to get the two graphs in Question 2
(1)
function Y = myFunction(d,n,theta)
Y = coinflip(100,100,0.25);
d = 100;
n = 100;
theta = 0.25;
Y = [ ];
for Dloop = 1:d
for Nloop = 1:n
X =rand(1);
Y = [Y;X];
end
end
Y(Y<theta) = 0;
Y(Y>theta) = 1;
histogram(Y)
xticks(0:1)
function Y = myFunction(d,n,theta)
Y = coinflip(100,100,0.5);
d = 100;
n = 100;
theta = 0.5;
Y = [ ];
for Dloop = 1:d
for Nloop = 1:n
X =rand(1);
Y = [Y;X];
end
end
Y(Y<theta) = 0;
Y(Y>theta) = 1;
histogram(Y)
xticks(0:1)
(2)
function Y = myFunction(d,n,theta)
Y = coinflip(10,1000,0.25);
d = 10;
n = 1000;
theta = 0.25;
Y = [ ];
for Dloop = 1:d
for Nloop = 1:n
X =rand(1);
Y = [Y;X];
end
end
Y(Y<theta) = 0;
Y(Y>theta) = 1;
histogram(Y)
xticks(0:1)
function Y = myFunction(d,n,theta)
Y = coinflip(10,1000,0.5);
d = 10;
n = 1000;
theta = 0.5;
Y = [ ];
for Dloop = 1:d
for Nloop = 1:n
X =rand(1);
Y = [Y;X];
end
end
Y(Y<theta) = 0;
Y(Y>theta) = 1;
histogram(Y)
xticks(0:1)
(3)
function Y = myFunction(d,n,theta)
Y = coinflip(100,1000,0.25);
d = 100;
n = 1000;
theta = 0.25;
Y = [ ];
for Dloop = 1:d
for Nloop = 1:n
X =rand(1);
Y = [Y;X];
end
end
Y(Y<theta) = 0;
Y(Y>theta) = 1;
histogram(Y)
xticks(0:1)
function Y = myFunction(d,n,theta)
Y = coinflip(100,1000,0.5);
d = 100;
n = 1000;
theta = 0.5;
Y = [ ];
for Dloop = 1:d
for Nloop = 1:n
X =rand(1);
Y = [Y;X];
end
end
Y(Y<theta) = 0;
Y(Y>theta) = 1;
histogram(Y)
xticks(0:1)

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by