Subscripted assignment dimension mismatch

Hiya . I have an issue with the code I am working on at the moment in which the simulation works fine for 3 hours average and then an error message pops up . I have the provided the codes . and this is the error meesage that I receive : Error using run_HF (line 33) Subscripted assignment dimension mismatch. I have linked all the files and the main runing file where the error occurs is run_HF . Thank you in advance .
Error in run_HF (line 20) parfor i = (1:1:slice_dim)

6 Commenti

What is your question? You cannot expect that the readers in the forum let your code run for 3 hours only to reproduce your problem. In addition we cannot even run your code at all due to the absence of the "genpath('smart-astro')" folder tree. In addition the line "parfor i = (1:1:slice_dim)" does not even appear in the posted codes, but "parfor i = 1:slice_dim". This looks similar, but it means the the code have been edited after the error was produced. And the next problem is, that you did not post a copy of the complete error message.
Therefore all I can do is to suggest to use the debugger: Type "dbstop if error" in the command window, let the code run again until it stops at the error, and then examine the locally used variables until it gets clear, which subscripted assignment fails.
Mohammed Aqelmoun's comment posted as an Answer moved here (please use comment on this question for further comments):
I do apologize for not writing a clear question . It was not my intention for anyone to run the simulations . My only issue is within the run_HF file . this is the error message that keeps popping up :
Error using run_HF (line 33) Subscripted assignment dimension mismatch.
Error in run_HF (line 20) parfor i = (1:1:slice_dim)
As pointed out by Jan, the code in the error message does not match the code in the function you've posted.
This means that we're not looking at the code you're actually running and thus you make it harder for us to identify the cause.
I would suspect that line 33 is
data_tot(i, :) = [subgrid(i,:),tmp];
adn therefore the error message tells you that the number of columns in data_tot is not equal to the number of columns in subgrid plus the number of columns in tmp.
Not having access to any of these variables we can't tell you why.
subgrid = grid(slice_dim*(id-1)+1:slice_dim*id,:) ,for id =1 gives a ( slice_dim,12) while tmp gives 2 clums which equals to 14 same as the data_tot where all data goes to . I dont know what is the issue is with the dimension all look good .
If the catch is not triggered in run_HF, then the badly named tmp variable will be the result of FABLE(...), so the DeltaV value in that function.
DeltaV is th result of another function in FABLE, so it's unknown if it is guaranteed to always be 2 columns. From your error, I would suspect that it is not guaranteed. As per Jan's comment, use dbstop if error and look at the state of the variables when the code breaks into the debugger upon error.
I followed what you said , by using the debugger the size of tmp= FABLE(departure_orbit,arr_obit) is 1x1 . Which I think leads to the error .how do i fix this even i am stating that it should be 2 columns?

Accedi per commentare.

Risposte (1)

Guillaume
Guillaume il 16 Gen 2018
That tmp, which is DeltaV in FABLE is created by the function LowThrustTransfer_OutOfPlane_new_param. So you will have to look in there to see why it's scalar (1x1). However, FABLE has clearly been written with the assumption that DeltaV is scalar, so really the problem is that your run_HF expects a 2x1 value from a function that is designed to return a scalar.
"how do i fix this"
There's clearly a break in logic in what you have written. We can't fix that for you. You have a function that wants orange and another that produces apples. You need to choose what you want, apples or oranges. We can't guess which is more right for you.

Categorie

Richiesto:

il 15 Gen 2018

Risposto:

il 16 Gen 2018

Community Treasure Hunt

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

Start Hunting!

Translated by