how to replace a data of an array with another array by comparing both arrays specific column having specific values?
Mostrar comentarios más antiguos
hello sir! i have an array having two column. array holds number of data with their priority 1 to 10(higher value means higher priority ) and know I have to put the data of this array according to their priorities into an another arrays . basicalyy 3 diffrent arrays of different size one array has limit 20 to hold data other has length 30 and the last array has the capacity to hold data is 40. these arrays have some values already in it. these array also have two columns (1st coulmn hold data in its 2nd column shows lru number 1 to 7 of that particular data . now I HAVE to evict the least recently used data having lru<7 and replace it with the data of an element with higher priority one by one using loops.
we can say from one main array we have to get value and then replece it with the others arrays value with less lru number .
main array may contain 1000 number of data with their priority number... basically all arays has same column number but different length.
please help me how to do that . i have done these steps through matlab build in command but I want to use loop because when large ammount of data is arrived then its not possible for me to put data one by one to kindly help me out to do that.
%initializing values with important data
% a=IWfmlih(1:20,1:1);
% A=a(:);
% randi([1 10], 40,1:1); % name as P
% L1=IWfmlih(11:20,4,:);
% randi([1 7], 10,1:1); % named as lru
% L1lru=cat(2,L1,lru);
% L1P=L1lru(:,1,2);
% %assigning priorities by concatenating arrays
% c=cat(2,A,P);
% L1lru=cat(2,L1,lru);
%evicting least recently used data using lru from L1P and placing higher priority
%data in L1P
% L1P(10,:)=c(16,:);
% L1P(9,:)=c(31,:);
% L1P(1,:)=c(24,:);
% L1P(3,:)=c(28,:);
% L1P(2,:)=c(32,:);
% L1P(5,:)=c(40,:);
% L1P(4,:)=c(3,:);
% L1P(6,:)=c(8,:);
%
% %using L2 Cache
% initializing values
% randi([1 7], 15,1:1); % named as LRU
% L2=IWfmlih(1:15,4,:);
% L2LRU=cat(2,L2,LRU);
% L2P=L2LRU;
%evicting least recently used data using lru from L2P and placing higher priority
%data in L2P cache
% L2P(5,:)=c(14,:);
% L2P(6,:)=c(17,:);
% L2P(10,:)=c(25,:);
% L2P(14,:)=c(2,:);
% L2P(15,:)=c(4,:);
% L2P(3,:)=c(10,:);
% L2P(11,:)=c(13,:);
% L2P(2,:)=c(26,:);
% L2P(4,:)=c(34,:);
% L2P(12,:)=c(6,:);
% L2P(9,:)=c(22,:);
% L2P(1,:)=c(23,:);
% L2P(13,:)=c(29,:);
%L2 CLEARED
%using L3 Cache
%initializing values
% randi([1 7], 20,1:1); %NAMED AS Lru
% L3=IWfmlih(1:20,5,:);
% L3Lru=cat(2,L3,Lru);
% L3P=L3Lru;
% %evicting least recently used data using lru from L2P and placing higher priority
% %data in L2P cache
% % L3P(13,:)=c(33,:);
% % L3P(1,:)=c(35,:);
% % L3P(2,:)=c(5,:);
% % L3P(3,:)=c(18,:);
% % L3P(4,:)=c(19,:);
% % L3P(9,:)=c(20,:);
% L3P(14,:)=c(38,:);
% L3P(17,:)=c(12,:);
% L3P(20,:)=c(21,:);
% L3P(6,:)=c(27,:);
% L3P(15,:)=c(30,:);
% L3P(5,:)=c(37,:);
% L3P(8,:)=c(7,:);
% L3P(12,:)=c(36,:);
% L3P(16,:)=c(39,:);
% L3P(18,:)=c(1,:);
% L3P(19,:)=c(9,:)
instead of doing all these one by one I want use loop to done this task. kindly help me out
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!