how to perform a vectorized operation with an array of multiple random numbers?

1 ビュー (過去 30 日間)
Mike Mierlo van
Mike Mierlo van 2019 年 9 月 28 日
コメント済み: Mike Mierlo van 2019 年 9 月 28 日
I want to perform multiple vectorized operations with the following numbers:
v_tank = 10.*rand(100,1)+35;
The code is:
clear all; close all; clc;
hold on
v_tank = 10.*rand(10,1)+35;
v_trailertank = 80;
v_trailer = 100;
t_loading = 1/12;
t_unloading = 1/12;
L = 400;
%the vector operations:
x = 100:0.01:150;
t_tank1=(t_loading+(x/v_trailertank)+t_unloading)+((L-x)/v_tank);
t_tank2=(t_loading+(x/v_trailertank)+t_unloading)+x/v_trailer+(t_loading+L/(v_trailertank)+t_unloading);
t_operation=max(t_tank1,t_tank2);
It can be seen that v_tank in the operation is an array of 100 random numbers. I want the vectorized operation be executed for all values of v_tank. I was thinking about a for-loop, but is impossible because v_tank are not positive integers. Please help.
  2 件のコメント
Mike Mierlo van
Mike Mierlo van 2019 年 9 月 28 日
Thank you! Beginners mistake from me.

サインインしてコメントする。

回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by