Filter löschen
Filter löschen

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

2 Ansichten (letzte 30 Tage)
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.

Akzeptierte Antwort

KSSV
KSSV am 14 Feb. 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

Weitere Antworten (0)

Kategorien

Mehr zu Function Creation finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by