how a access array element and send to user for task
1 次查看(过去 30 天)
显示 更早的评论
This is my code
% Structure of array user set
user(1).will = 0.5;
user(1).rep = 1;
user(1).bid = [9,8,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;
s = 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);
s((i-1)*3+j)= com_data_quality;
b = 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.250000 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
b =
0.7560 0.6300 0.5400 0.2857 0.2500 0 (decending order)
Now my question is here array b is in decending order of com_data_quality,here user 2 for task 2 give the highest data quality i want to send this task for user 2...and then assign the task to user with highest data quality.
how i write this code for this process.
Please help me.
5 个评论
Jan
2019-3-26
@Sanjoy Dey: These explanations are still to abstract to understand, what you want to do. There is no Matlab command to perform a "involve some person" or "send task 1 to user 2".
Matlab could send an email, if the address is known. Or you can create a struct, which contains the field "solvedBy" and set the contents to the char vector "user 1". Maybe you want to store a specific file in a certain folder. You still did not mention, what the code should do.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!