How to create an empty array to be filled?
2 541 views (last 30 days)
I have this:
(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!
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.
More Answers (3)
TADA on 18 May 2020
Ma is a 0x0 empty vector:
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
Kamilu Sanusi on 27 Aug 2022
Hello everyone. Please can someone explain the essense of creating empty matrix A, B, YG, & E in the following program:
[Gen, delta, Eq]=Generator(DatGen(i,:), arbeitspunkt);
% Matrix der Systemgelcihung von Generator i
% Matrix der Systemgelcihung von allen Generatoren
Alisha on 23 Sep 2022
Edited: Steven Lord on 23 Sep 2022
[SL: removed spam link]
It is not possible to create a blank array and then allow it to grow dynamically each time a user types a number into the command line. Instead, you ought to read the integers and add them to an Array. An ArrayList can grow dynamically and does not require an initial size.