how we can store value in array using loop?
Show older comments
user(1).will = 0.5;
user(1).rep = 1;
user(1).bid = [3,5,7];
user(1).inter_time=4;
user(2).will = 0.9;
user(2).rep = 0.6;
user(2).bid = [6,5,7];
user(2).inter_time=7;
% Structure of Array of user set
task(1).bud = 8;
task(1).qua = 1;
task(2).bud = 9;
task(2).qua = 2;
task(3).bud = 7;
task(3).qua = 1;
%a = zeros(1,3*2);
%b=zeros(1,3*2);
%c=zeros(1,3*2);
for i=1:2
for j=1:3
%fprintf('i=%d j=%d\n',i,j);
if(not (user(i).bid(j)<=task(j).bud))
continue;
end
com_data_quality = (user(i).will*user(i).rep/user(i).bid(j)*user(i).inter_time);
%a((i-1)*3+j)= com_data_quality;
%b((i-1)*3+j)=i;
%c((i-1)*3+j)=j;
%c = sort(s,'descend');
fprintf('value is %f task is=%d user is=%d \n', com_data_quality,j,i);
end
end
OUTPUT:
value is 0.666667 task is=1 user is=1
value is 0.400000 task is=2 user is=1
value is 0.285714 task is=3 user is=1
value is 0.630000 task is=1 user is=2
value is 0.756000 task is=2 user is=2
value is 0.540000 task is=3 user is=2
This is ouput of my code but i want store this value in 3*3 matrix in which first row store value second row store corresponding task number and 3rd row store user...how it's possible in matlab?HELP ME

Accepted Answer
More Answers (0)
Categories
Find more on Cell Arrays 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!