필터 지우기
필터 지우기

How do i run through multiple arrays

조회 수: 1 (최근 30일)
Rose
Rose 2019년 9월 28일
편집: dpb 2019년 9월 28일
I have multiple arrays filled with 10 random numbers between certain values. Now I'm trying to get the equations below (t_tank1, t_tank2, t_operation) to loop through the random number arrays, to take the first value out of every array, secondly the second value out of every array etc, to finally create a 10x1 array of t_operation. However, i keep ending up with a 10x10 matrix. I tried using a For loop, but can't seem to get it to work. Any help here?
% Defining Variables
L=400 %km​
v_tank = unifrnd(30,50,10,1)
v_trailer = unifrnd(90,110,10,1)
v_tt = unifrnd(70,90,10,1)
t_l= unifrnd(0,(1/6),10,1)
t_ul= unifrnd(0,(1/6),10,1)
% ​
%3a: lets say x=200 km​
x=200 %km​
t_tank1=(t_l+x/v_tt+t_ul)+(L-x)/v_tank
t_tank2=(t_l+x/v_tt+t_ul)+x/v_trailer+(t_l+L/v_tt+t_ul)
t_operation=max(t_tank1,t_tank2)

채택된 답변

David Hill
David Hill 2019년 9월 28일
t_tank1=(t_l+x./v_tt+t_ul)+(L-x)./v_tank;
t_tank2=(t_l+x./v_tt+t_ul)+x./v_trailer+(t_l+L./v_tt+t_ul);​​

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by