Effacer les filtres
Effacer les filtres

How to create a matrix array with increments equation using vectorization?

2 vues (au cours des 30 derniers jours)
Teb Keb
Teb Keb le 14 Fév 2022
Commenté : Teb Keb le 14 Fév 2022
I am trying to create a matrices array after calculating the area and volume of a system with increment equations. Basically the area and volume are changing from 1 to 10 seconds with 1 second increments. Then I have to create a matrix array showing the time with increments row as first column and corresponding calculated area and volume as the second and third column of the matrix using vectorization.
s=0.1;
y=pi;
x=1:1:5;
area=s.*sqrt(y.*x);
vol=s.*y*sqrt(y.*x);
B=[x area vol];
So basically my matrices should be 5x3. But I am confused as to how I can put the rows as increments, I am getting 1x15 matrices.

Réponse acceptée

KSSV
KSSV le 14 Fév 2022
s=0.1;
y=pi;
x=[1:1:5]'; % transpose this
area=s.*sqrt(y.*x);
vol=s.*y*sqrt(y.*x);
B=[x area vol];
size(B)
ans = 1×2
5 3

Plus de réponses (0)

Catégories

En savoir plus sur Function Creation dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by