'Dimensions of arrays being concatenated are not consistent' when using isequal

1 visualizzazione (ultimi 30 giorni)
[updated1, dist1] = googleMaps(map1, dir1);
[updated1_soln, dist1_soln] = googleMaps_soln(map1, dir1);
t10 = isequal([updated1, dist1], [updated1_soln, dist1_soln])
Where running t10 prints the error:
Error using horzcat
Dimensions of arrays being concatenated are not consistent.
Error in hw07 (line 107)
t10 = isequal([updated1, dist1], [updated1_soln, dist1_soln])
I am not trying to concatenate, why is it printing that?
I'll add the variables (as a disclaimer, they won't make much sense, I'm running this to compare answers for a hw assignment)
Running an == comparison gives:
>> dist1 == dist1_soln
ans =
logical
1
>> updated1 == updated1_soln
ans =
5×5 logical array
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
>>
And the variables are:
updated1
val =
' '
' '
'x## '
' # '
' o '
updated1_soln
val =
' '
' '
'x## '
' # '
' o '
dist1 and dist1_soln are both 4 1x1 doubles. I don't understand why isequal is doing this though, I've used it for things like this often, without getting that error.

Risposta accettata

the cyclist
the cyclist il 5 Ott 2019
Modificato: the cyclist il 5 Ott 2019
What sizes are updated1 and dist1 (and the other pair)?
[updated1, dist1]
  3 Commenti
the cyclist
the cyclist il 5 Ott 2019
The syntax
[updated1, dist1]
inside of the isequal command is trying to concatenate a 5x5 logical array with a 4x1 double (before it checks with the other argument for equality). That will cause an error. That syntax for the isequal command is not comparing
updated1 == updated1_soln
and
dist1 == dist1_soln
"in parallel", as you seem to intend.
The reason that your other case works is that one can horizontally concatenate
'Player 1 wins!'
and
[11 6 8 4 13 9 10 3 12 7 5 2]
into a character vector.
Instead, you'll need to do something like
isequal(updated1, updated1_soln) && isequal(dist1, dist1_soln)
Julia Sequerth
Julia Sequerth il 5 Ott 2019
I guess I've just been lucky that it concatenated until this point, I'll be sure to separate them in the future. Thank you!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by