incompatible array sizes for 2x1 column vectors

3 ビュー (過去 30 日間)
Timothy Dunning
Timothy Dunning 2022 年 12 月 2 日
回答済み: Timothy Dunning 2022 年 12 月 7 日
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 件のコメント
Thomas
Thomas 2022 年 12 月 7 日
Just want to add that you can use function isrow and iscolumn to validate what MATLAB defines as row and column vectors respectively.

サインインしてコメントする。

採用された回答

Timothy Dunning
Timothy Dunning 2022 年 12 月 7 日
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 件)

カテゴリ

Find more on Construct and Work with Object Arrays in Help Center and File Exchange

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by