Prev: xlsread-multiple sheets
Next: Integer operands are required for colon operator when used as index
From: the cyclist on 20 Oct 2009 09:08 "Johan-Mark Sikkema" <johanmark82(a)gmail.com> wrote in message <hbkcca$4r7$1(a)fred.mathworks.com>... > Hi, > > I have a vector of values Ar, then I calculate a value Re1 with a logical vector so for certain vector values Re is calculated otherwise 0 is put in the vector. The vector Re1 is used to calculate a vector Cd1. > I do this to create 3 vectors Re and 3 vectors Cd. at the end I add the vectors with Re = Re1 + Re2 +Re3, and I do the same for Cd. > > Here's and example of code to show the logic. > ----------------------------- > Ar =[30 500 90000] > Re1 = ((Ar <36).*Ar)./18 % the part (Ar <36) gives the logical vector [1 0 0] > Cd1 = 24./Re1 > -----------------------------end of code segement! > > The result is a vector Re1 = [14.4 Inf Inf ], because of the 0 elements in vector Re1 we devide 24 with. > This is a problem because every vector element gets replaced by Inf when adding the vectors at the end, this would not happen with 0's (zeroes). > > Is there a method of replacing the Inf values in the vector by 0's but leaving the values that are not Inf? so Re1 = [14.4 0 0 ], in stead of [14.4 Inf Inf]. > > I've tried things with isinf(Re1), but this replaces the 14.4 element by 0 and gives 1's for the Inf elements. > > P.S. I don't want to use any if statements to solve this problem! > > with kind regards, > Johan-Mark You almost got there! >> Re1(isinf(Re1)) = 0;
|
Pages: 1 Prev: xlsread-multiple sheets Next: Integer operands are required for colon operator when used as index |