# incompatible array sizes for 2x1 column vectors

4 Ansichten (letzte 30 Tage)
Timothy Dunning am 2 Dez. 2022
Beantwortet: Timothy Dunning am 7 Dez. 2022
I have an array, z, with 2 rows and an iteratively expanding amount of columns the first of which is assigned: z(:,1) = [0,2500];
I pass the current (nth number) value of the array with z = ivpsolver(z(:,n)) and then again with z(:,n+1) = rungekutta(z(:,n));
in this function I get an error on a line that says: znext = z + (1/6)*(Az+2*Bz+2*Cz+Dz); where Az, Bz, Cz and Dz are 1x2 column vectors (as z should be). The error states "Arrays have incompatible sizes for this operation."
am I missing something obvious or is the error likely somewhere else?
##### 6 Kommentare4 ältere Kommentare anzeigen4 ältere Kommentare ausblenden
Gokul Nath S J am 7 Dez. 2022
Verschoben: the cyclist am 7 Dez. 2022
Hi Timothy Dunning,
As per my understanding, you are calling ivpSolver with five arguments while the function demands for six of them. Check whether all the arguments are properly passed to the function.
Further, the entity [0, 2500] is a row vector of dimension 1 x 2. If your requirement is a 2 x 1 column vector, you might need to specify it as [0; 2500].
Thomas am 7 Dez. 2022
Just want to add that you can use function isrow and iscolumn to validate what MATLAB defines as row and column vectors respectively.

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Timothy Dunning am 7 Dez. 2022
Thanks all, you were all right, i was passing the wrong number of variables but I also had another issue elsewhere that was causing the array, z, to be 1x3 instead of 1x2
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Programming finden Sie in Help Center und File Exchange

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by