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

1 visualización (últimos 30 días)
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 comentarios
Walter Roberson
Walter Roberson el 28 de Sept. de 2019
Change your / to ./
If you were using * or ^ then you would change those to .* and .^

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices 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