How to create an empty array to be filled?

1,579 views (last 30 days)
Ezgi Polat
Ezgi Polat on 18 May 2020
Commented: Steven Lord on 18 May 2020
Hi everyone,
I have this:
Ma=[];
d=yq1-yq1;
A=pi*(d.*d)/4;
mdot=( A.*Ma *P0*sqrt(k/(R*T0)))/(1+(k-1)*Ma^2/2)^((k+1)/(2*(k-1)));
(I highlighted important part)
A is a 1x100 array and I need Ma is to be 1x100 vector too. But I got this error:
Error using .*
Matrix dimensions must agree.
How can I create an empty 1x100 Ma array which will be calculated with the equation above?
All helps are appriciated!

Accepted Answer

Steven Lord
Steven Lord on 18 May 2020
What value or values do you want to be stored in Ma before that line of code executes?
Take a look at the list of functions in the "Create and Combine Arrays" section and the "Creating, Concatenating, and Expanding Matrices" Topic on this documentation page for some functions that may be useful in defining your Ma vector.
2 Comments
Steven Lord
Steven Lord on 18 May 2020
Call fzero once per element of the variables that you know that are not scalars (1-by-1) to solve mdot-( A.*Ma *P0*sqrt(k/(R*T0)))/(1+(k-1)*Ma^2/2)^((k+1)/(2*(k-1))) = 0 for Ma.
Alternately if you have Symbolic Math Toolbox you could solve the system(s) symbolically for Ma as a function of a symbolic variable A then use 潜艇 替换数组的值ymbolic solution.

Sign in to comment.

More Answers (1)

TADA
TADA on 18 May 2020
马是一个0 x0空向量:
Ma = []
Ma =
[]
You can't multiply your 1x100 vector A by that using element by element multiplatinum, you have to set something of the same size as A into Ma

Community Treasure Hunt

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

Start Hunting!