please i have a question in matlab can any one help me please i want to correct this code ? i dont understand the error

N=32;
t=100;
R=1000;
c=[];
nprime=50;
for n=1:t
for u=1:R
% c=perform_read_cycle(N,c);
c=(1-(1-(1/N)).^t )*(1+(n/(N-1)));
% n(u)=estimate_tags(N,c);
n(u)=rand(1,1000);
e(u)= rand (1,100);
e(u)=n(u)-nprime;
end
% u(n')=n(u)-n';
% u=mean(eu,R);
end
plot(e(u),t);

4 Comments

You haven't even asked a question. Just posted some code (which I had to format for you).
See also this answer
yeah i forget to asked :/ :/ but i wanna one to correct or just explain to me the error in this code
You claim that your question is "urgent" but do not ask a question? You want the readers to explain the error of your code but do not take the time to explain, why you assume that there is an error? This is a bad strategy to get help and another example for questions, which contain the term "urgent", but do not provide even enough information to be answered efficiently.
excuse me for the manner in which I asked the question i mean by the term "urgent" : " i need this now because im stressed with time" any way thanks for your advices :) :)

Answers (1)

e(u) is the u-the element of the vector e, thus a single number. In the command
e(u)= rand (1,100);
you try to assign a vector with 100 elements to this single number. This is not possible.
(Same for n(u)).
Best wishes
Torsten.

7 Comments

Another issue is that you (try to) assign a value to the variable n which is also a loop variable. Either the loop variable or the destination needs to change name.
Replace these lines:
n(u)=rand(1,1000);
e(u)= rand (1,100);
e(u)=n(u)-nprime;
with this:
e(u)= rand(1) - nprime;
ah thanks now i get the correct code but what you mean by rand (1) ???
#
N=32;
t=100;
R=1000;
c=[];
nprime=50;
for n=1:t
for u=1:R
% c=perform_read_cycle(N,c);
c=(1-(1-(1/N)).^t )*(1+(n/(N-1)));
% n(u)=estimate_tags(N,c);
e(u)= rand(1) - nprime;
end
% u(n')=n(u)-n';
% u=mean(eu,R);
end
plot(e(u),t);
#
i mean a get a code without error but i get an empty figure :/
ah oki (y) and rand(1) please what does that mean ?
rand(1) means to create a 1 x 1 array of uniformly distributed random numbers in the range 2^(-53) to (1-2^(-53)) inclusive (that is, (0,1) exclusive)

This question is closed.

Products

Tags

No tags entered yet.

Asked:

on 20 Jul 2015

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!