how to use array indices in not logical form
    3 views (last 30 days)
  
       Show older comments
    
Hi 
I am working on a project and I have the equation below and when I use for loops because my T is a float Number something like 0.15 I get an error that I should use positive or logical numbers how sholud I fix that ??
thank you 

3 Comments
  Walter Roberson
      
      
 on 25 Jul 2022
				    tm(i,:) = ((1/qu(i))*(delta_x/speed(i)));
tm is a vector or perhaps a 2D array. Not scalar.
beta = 0.8;
alpha = 0.5;
ta = beta*tm; %lag time 
ta is a constant multiple times tm, and tm is non-scalar so ta is non-scalar.
for j =ta:ta+length(qu))
What does it mean to have a for loop whose lower bound is an array ?
    qd(:,j) = ((((1-Ftu).^(j-ta(j)))).*Ftu)*qu(j)
Suppose the for loop somehow managed to assign the full array ta to j . Then you use ta(j) so you would be indexing ta at the values of ta . Are you sure that is wise? 
Answers (1)
  Walter Roberson
      
      
 on 25 Jul 2022
        syms F_cyc_k i q_up T t 
assume(0 < F_cyc_k & F_cyc_k < 1)
assume(T > 0)
q_down = symsum( ((1-F_cyc_k)^(i-T) * F_cyc_k)*q_up*(t-i), i, T, inf)
The limit would be different if 
 might be outside the range 0 to 1 exclusive, or if T might be negative.
0 Comments
See Also
Categories
				Find more on Matrices and Arrays in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!