How can I solve this error (Improper assignment with rectangular empty matrix.) with listed below script. Thanks

elevtocellsI1=accumarray(OrbNO,elev2,[],@(x) {x});
DDDD=zeros(1,size(elevtocellsI1,1));
for i=1:size(elevtocellsI1,1)
DDDD(i)=(find(elevtocellsI1{i}, 1, 'last' )-(find(elevtocellsI1{i}, 1 )))/60;
end
figure(567432)
bar(DDDD)
title('Passage Time Over the GS')
xlabel('time(Seconds)')
ylabel ('Passage Time (min)'),
grid on

2 Comments

@Oday Shahadh: please edit your question and give us the complete error message. That means all of the red text.
Also it helps if you give us code that actually works (so that we can run it), otherwise we have to rely on using our magic crystal balls to read what is on your computer monitor.
Improper assignment with rectangular empty matrix.
Error in BAN_FINAAl (line 710) DDDD(i)=(find(elevtocellsI1{i}, 1, 'last' )-(find(elevtocellsI1{i}, 1 )))/60;

Sign in to comment.

 Accepted Answer

Some of the cells resulting from accumarray are likely to be empty. find(elevtocellsI1{i}, 1, 'last' ) on the empty cell is going to be empty. (find(elevtocellsI1{i}, 1, 'last' )-(find(elevtocellsI1{i}, 1 )))/60 would then be empty. You try to assign that emptiness to a definite location DDDD(i)

11 Comments

I am trying to estimate the time that the satellite sped over a ground station which is the difference between the time index of the first and the last values of each cell, that what I was tried in the: DDDD(i)=(find(elevtocellsI1{i}, 1, 'last' )-(find(elevtocellsI1{i}, 1 )))/60;
so if there is a way to ignored or eliminate any empty cell in the loop I would appreciate.. thanks
elevtocellsI1=accumarray(OrbNO,elev2,[],@(x) {x}, inf);
This fills in inf in the locations where there is no data. inf is not NaN and not 0, so find() is able to find it. the 1 'last' location found will be the same as the first location, and the difference between those indices will be 0, giving you an output of 0.
However, I have to question whether you really want to take the difference in indices. The only thing in the cells will be the data that matches.
In the special case where all of the data is known to be non-zero, then the difference in indices would be length() of the data minus 1 -- but at the same time I suspect that what you would want instead would be length() of the data without subtracting 1.
In the case where some of the data could be 0, then the results would depend on the order of the data. Perhaps that is what you want, but as an on-looker I have to wonder if it is right?
Dear Walter, I appreciate you efforts here, the index here is the time step of the ODE45, so if we say that the index of the first value of the cell is 100 and the last vindex of the last value of the cell is 500 this mean the satellite spent 400 seconds, and this just in case of a non-zero cells,some times is difficult to explain here because this script is apart of about 1400 syntax, what ever I tried your syntax and that what I got
Error using accumarray FILLVALUE and output from the function '@(x){x}' did not have the same class.
Error in BAN_FINAAl (line 705) elevtocellsI1=accumarray(OrbNO,elev,[],@(x) {x}, inf);
Any way I really appreciate your efforts
I tried again and got the same first error, Do not worry my friend you did the best. thank you very much
Improper assignment with rectangular empty matrix.
Error in BAN_FINAAl (line 708) DDDD(i)=(find(elevtocellsI1{i}, 1, 'last' )-(find(elevtocellsI1{i}, 1 )))/60;
Time-steps in ODE45 are not equal distance apart. If you are passing indices of the times to accumarray then you are not taking into account that the timesteps are different width. You would need to use the indices to index into the timestamps and subtract the timestamps.
If you are passing the timestamps themselves into accumarray, then I would suggest to you that it might be more appropriate to take max() of the timestamps minus min() of the timestamps (unless, that is, there can be gaps such as if the same location is covered twice in different orbits.)
You might want to consider modifying your accumarray, using something more like
DDDD = accumarray(OrbNO,elev2,[],@(x) max(x)-min(x), 0);
with no need for a post-processing loop.
Dear Walter I think it is partially solved, five bars appeared represents five passages, but it dose not refer to how much time the satellite spent over
I attached the elevation plot, in which each line segment on the time axes under each the fives curves represents the time the satellite spent over the GS
I need to do something else for a while; I will have a look later this evening.

Sign in to comment.

More Answers (0)

Categories

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!