From: Jan Simon on 16 Dec 2009 16:58 Dear Hanna! > thanks for your answer. No that is not what I want. I want all statements to be true. I am going to be more specific: I have 2 matrices (coups and maturity) and I want that the empty elements of coups shall be filled with zeros when the emelents on the same place on mats are not empty and not a nan, hence the three statements. > for ii=length(coups(:,1)); > for dd = 1:length(coups(1,:)); > if isnan(coups(ii,dd)) && isempty(mats(ii,dd))==0 && isnan(mats(ii,dd))==0; > coups(ii,dd)=0; > end; > end; > end; It is not possible in Matlab, that an element of a matrix is empty! You could do this with cell arrays, but even then not the corresponding cell is empty, but the contents of the cell. In this case, you'd have something like: if isnan(coups{ii,dd}) && isempty(mats{ii,dd})==0 && isnan(mats{ii,dd})==0; Please clear, what you mean with "isempty(mats(ii, dd))". Finally I think your actual problem should be solved by something like this: coups(isnan(coups) & ~isnan(mats)) = 0 Good luck, Jan
First
|
Prev
|
Pages: 1 2 Prev: Interpolation in an unstructured field Next: how to convert html to pdf |