could anyone tell me how to store the result of each iteration in an array for the following code

 Accepted Answer

t=4;
r=6;
for it=1:4
output(t,r)=overall_throughput;
output_it(t,r,it)=output(t,r);
all_output{it} = output;
all_output_it{it} = output_it;
end
Now a complete record of the results of the iterations is stored in all_output and all_output_it

5 Comments

When i run the following code i am getting error
Conversion to cell from double is not
possible.
Bmax=3000;
noise=10;
A=[0 0 0 0 0.0447 0
0 0 0 0 0.0294 0]
B=[0 0 0 0 0.2428 0
0 0 0 0 0.4424 0]
A=[0 0 1.9728 0 0 0
0 0 0.0000 0 0 0]
B=[0 0 0.1971 0 0 0
0 0 0.2703 0 0 0]
A=[0.2373 0.2169 0 0.1979 0 0.2098
0.0174 0.0186 0 0.0214 0 0.0249]
B=[0.2160 0.7904 0 0.4386 0 0.8620
0.3774 0.9493 0 0.8335 0 0.9899]
N = length(A) ;
throughput = cell(N,1) ;
for v =1:size(B,2)
for u =1:size(A,1)
for k =1:N
throughput{k}=throughput(u,v)
throughput(u,v) =(Bmax.*log2(1+(((A(u,v)).*(B(u,v))/(noise+sum(B(1:u-1,v)).*A(u,v))))))
end
end
end
could you please help me on this.
On the line
throughput{k}=throughput(u,v)
you are taking the content of the cell array throughput(u,v) and placing the cell array as the content of throughput(k, 1), resulting in nested cell arrays.
On the line
throughput(u,v) =(Bmax.*log2(1+(((A(u,v)).*(B(u,v))/(noise+sum(B(1:u-1,v)).*A(u,v))))))
you are taking the numeric value after the "=" and trying to store it as if it were a cell array into location throughput(u,v) .
Perhaps instead of using throughput(u,v) in those places, you might want throughput{u,v}
And it is really not recommended to mix linear indexing {k} with two-dimensional indexing in the same group of code.
If you end up mixing () notation on a cell and {} notation on the cell, then you should double-check the code to be sure you really want to work with the content as being containers, which is () notation, or if you want to work with what is inside the containers, which is {} notation. Sometimes it makes sense to use both in the same block of code, but more often it indicates that cells are being misused.
ok. could you tell me is there any other way to solve the issue for the following code:
A=[0 0 0 0 0.0447 0
0 0 0 0 0.0294 0]
B=[0 0 0 0 0.2428 0
0 0 0 0 0.4424 0]
A=[0 0 1.9728 0 0 0
0 0 0.0000 0 0 0]
B=[0 0 0.1971 0 0 0
0 0 0.2703 0 0 0]
A=[0.2373 0.2169 0 0.1979 0 0.2098
0.0174 0.0186 0 0.0214 0 0.0249]
B=[0.2160 0.7904 0 0.4386 0 0.8620
0.3774 0.9493 0 0.8335 0 0.9899]
for v =1:size(B,2)
for u =1:size(A,1)
throughput(u,v) =(Bmax.*log2(1+(((A(u,v)).*(B(u,v))/(noise+sum(B(1:u-1,v)).*A(u,v))))))
end
end
I have modified the line to
throughput{u,v} =(C.*log2(1+(((A{u,v}).*(B{u,v})/(w+sum(B(1:u-1,v)).*A{u,v})))))
but still i am getting error. Cell contents reference from a non-cell array object.

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!