how to perform a vectorized operation with an array of multiple random numbers?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 28 Sep 2019
Change your / to ./
If you were using * or ^ then you would change those to .* and .^
Réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!