Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Matrix Dimension error with no clear source

1 visualización (últimos 30 días)
Matt
Matt el 6 de Sept. de 2016
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi! I'm basically brand new to MATLAB and have written a rather lengthy code for a series of ODEs (currently using ode15s as a solver, but have tried others) and my code will only run for a t-span of exactly 33 seconds (probably some decimal beyond 3e), but I want it to run for a t-span of at least 100.
At some point around that 33 mark I get an error of:
Matrix dimensions must agree.
Error in Remyelination_analysis (line 65)
difference = dataDisease - dataHealthy;
The "difference" is a global variable referring to a matrix made by subtracting the two other matrices seen above. If I'm right it's claiming the matrices end up different sizes and that's why it is stopping, but they should all be the exact same size! They all have the same variables in them, but the two matrices being subtracted would have different amounts of zeroes as variables if that makes any difference.
I've checked the workspace and all three matrices are popping up at different sizes"
303x404 double, 339x404 double, and 301x404 double
Any ideas on what to try would be great! Changing my ODE solver doesn't do the trick. ode23tb seemed to be working best, but it eventually got stuck and I had to cancel the run.
Thanks!

Respuestas (1)

Matt J
Matt J el 6 de Sept. de 2016
Editada: Matt J el 6 de Sept. de 2016
Well, I think you've answered your own question. You've confirmed that the matrices have different sizes, so the source of the matrix dimension error is quite clear. You should go to the lines where dataDisease and dataHealthy are created and set Conditional Breakpoints to trap the cases where their sizes are incorrect.
Also, be mindful of the risks of using global variables.
  2 comentarios
Matt
Matt el 13 de Sept. de 2016
So I think I've identified the issue. Using a tic tic function I was able to see that dataHealthy is taking far less time to solve than dataDisease, and when I altered one key variable value, this disparity vanishes and the system seems to run. Any ideas on how to resolve this issue such that I can keep the normal value in dataDisease?
James Tursa
James Tursa el 13 de Sept. de 2016
Not without seeing your code.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by