From: Ozge Taskan on 8 Jun 2010 13:42 Hi, I am trying to prepare a matrix, I have a for loop and in this loop I increase every number in the matrix by one and make some calculations, when I finish my calculations then I need to say fix one number in my matrix and make zero the other numbers in the same row. Same calculations need to be done again from the beginning however these zero values mustn't change. I need to fix these zero values and try to put these numbers in quarantine and these numbers should not be affected by any calculations. for example I will start with s=zeros(5,5) I will find s(1,5) should be 1 then I will fix all numbers as 0 in this row except 5th column number, s(1,1)=s(1,2)=s(1,3)=s(1,4)=0. Then continue my calculations by increasing each number except these 0 values by 1, these zeros will never be affected from any calculations? How can I do that? I hope my question is clear. I really need help. I appreciate your help and time. Thank you very much in advance. Oz
From: Walter Roberson on 8 Jun 2010 16:11 Ozge Taskan wrote: > I am trying to prepare a matrix, I have a for loop and in this loop I > increase every number in the matrix by one and make some calculations, > when I finish my calculations then I need to say fix one number in my > matrix and make zero the other numbers in the same row. Same > calculations need to be done again from the beginning however these zero > values mustn't change. I need to fix these zero values and try to put > these numbers in quarantine and these numbers should not be affected by > any calculations. for example I will start with > s=zeros(5,5) > I will find s(1,5) should be 1 then I will fix all numbers as 0 in this > row except 5th column number, s(1,1)=s(1,2)=s(1,3)=s(1,4)=0. Then > continue my calculations by increasing each number except these 0 values > by 1, these zeros will never be affected from any calculations? How can > I do that? Perhaps something like this? CanVary = false(5,1); .... CanVary(5) = true; s(1,~CanVary) = 0; .... s(1,CanVary) = s(1,CanVary) + 1;
|
Pages: 1 Prev: pre-allocation of a compex matrix Next: SimscapeHydraulic motor not turning |