how to use array indices in not logical form

1 visualización (últimos 30 días)
arash rad
arash rad el 25 de Jul. de 2022
Comentada: Walter Roberson el 25 de Jul. de 2022
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 comentarios
arash rad
arash rad el 25 de Jul. de 2022
Editada: Matt J el 25 de Jul. de 2022
%-- Extract some data
arrival=xlsread('tripinfo.xlsx','G:G');
depart_time=xlsread('tripinfo.xlsx','B:B');
speed_m = xlsread('loop.xlsx','G:G');
N_veh = xlsread('loop.xlsx','J:J');
Nt = length(speed_m)/2;
speed = zeros(Nt,1);
vehicle_number = zeros(Nt,1);
qu = zeros(Nt,1);
%-- Here we calculate number of vehicles that we need for calcualtion
%parameters
for k = 1:Nt;
speed(k,1) = [speed_m((2*k)-1) + speed_m(2*k)]/2;
vehicle_number(k,1) = [N_veh((2*k)-1) + N_veh(2*k)];
qu(k,:) = vehicle_number(k,1);
end
speed;
vehicle_number;
qu = qu';
%-- first we want to extract data from sumo in every 10 minutes.in step one
%we want to calculate how many cars are in the intersection in specific
%intersection
figure;
bar(qu)
title("Upstream Flow")
%% calculate parametrs
delta_x = 500 - 70 ;
T = zeros(Nt,1);
for i =1:length(qu)
tm(i,:) = ((1/qu(i))*(delta_x/speed(i)));
T(i) = delta_x/(speed(i)); %lag time
end
tm ;
beta = 0.8;
alpha = 0.5;
ta = beta*tm; %lag time
Ftu_den = 1+(alpha*ta);
Ftu = 1./Ftu_den;
%% Arriving flow distribution
qd = zeros(Nt,1);
for j =ta:ta+length(qu))
qd(:,j) = ((((1-Ftu).^(j-ta(j)))).*Ftu)*qu(j)
end
Walter Roberson
Walter Roberson el 25 de Jul. de 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?

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 25 de Jul. de 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)
q_down = 
The limit would be different if might be outside the range 0 to 1 exclusive, or if T might be negative.

Categorías

Más información sobre Operators and Elementary Operations en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by