Oct-10-2019, 08:41 AM
This is the Matlab cycle that I'm trying to reproduce:
j = 1;
while j < max(length(H_ev_hf_vec),length(H_ev_wf_vec))-1
Q_ev_hf = m_hf*(H_ev_hf_vec(j+1)-H_ev_hf_vec(j));
Q_ev_wf = m_wf*(H_ev_wf_vec(j+1)-H_ev_wf_vec(j));
if Q_ev_hf > Q_ev_wf
H_ev_hf_vec = [H_ev_hf_vec(1:j), H_ev_hf_vec(j)+Q_ev_wf/m_hf, H_ev_hf_vec(j+1:end)];
elseif Q_ev_hf < Q_ev_wf
H_ev_wf_vec = [H_ev_wf_vec(1:j), H_ev_wf_vec(j)+Q_ev_hf/m_wf, H_ev_wf_vec(j+1:end)];
end
j = j+1;
end
But I can't find a way of doing it in Python.
Instead of the command "append", I think it would be more indicated the command "extend", but I'm not able to insert it in the for cycle.
Any solution?
j = 1;
while j < max(length(H_ev_hf_vec),length(H_ev_wf_vec))-1
Q_ev_hf = m_hf*(H_ev_hf_vec(j+1)-H_ev_hf_vec(j));
Q_ev_wf = m_wf*(H_ev_wf_vec(j+1)-H_ev_wf_vec(j));
if Q_ev_hf > Q_ev_wf
H_ev_hf_vec = [H_ev_hf_vec(1:j), H_ev_hf_vec(j)+Q_ev_wf/m_hf, H_ev_hf_vec(j+1:end)];
elseif Q_ev_hf < Q_ev_wf
H_ev_wf_vec = [H_ev_wf_vec(1:j), H_ev_wf_vec(j)+Q_ev_hf/m_wf, H_ev_wf_vec(j+1:end)];
end
j = j+1;
end
But I can't find a way of doing it in Python.
Instead of the command "append", I think it would be more indicated the command "extend", but I'm not able to insert it in the for cycle.
Any solution?