how to use array indices in not logical form
1 回表示 (過去 30 日間)
古いコメントを表示
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1076195/image.png)
3 件のコメント
Walter Roberson
2022 年 7 月 25 日
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?
回答 (1 件)
Walter Roberson
2022 年 7 月 25 日
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1076255/image.png)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!