i have trouble with load.it change matrix size.

5 views (last 30 days)
hi. i wrote a script that i use a loop in it for reading multiple image ( actually they are matrix with .data format). i have load function in this loop. my matrix is 730*13764 but when loaded by load function it changes to 730*1734 and my proccess stoped. what can i do? please help. it's for thesis.
  3 Comments
mahdi khabazi
mahdi khabazi on 2 Sep 2021
Edited: mahdi khabazi on 2 Sep 2021
hi. thanks for your answer. i attached five pic of code. my problem is in line 147 when use load. for Additional explanation i should say this code is for time series and before use matrixs in this code, they process in another software and it's output use in this code. but in line 147 when the load function worked, the size of matrix would change. in line 57, output bands must be 730 (i edited it and tried with 730 but not work). the error comes below. i hope you can help me. thanks.
Error using reshape
Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
Error in SSA_reconstructed_tool (line 152)
data{ind} = reshape( data{ind}', upref.coldist(ind),...
dpb
dpb on 2 Sep 2021
We can't do anything useful with images -- attach the pertinent code as text itself so we can read/edit/fiddle...
Again I'll reiterate -- post the result of
whos -file YOURFILENAME
will be much more informative -- that'll tell you what the array size really was when it was save.
In a glance at the images I didn't see any load statement at all; I did see that you appear to have hardcoded in array sizes at the beginning of the function. This is poor practice and will, as you've seen, result in fragile code that won't work for data sets other than that specific size instead of being generic code to make a particular type of analysis on an input array of whatever size it might be.
If it MUST for some reason be that size, then your job will be to make sure it is before you get that far by whatever means you must...but that's probably not the ideal solution; the better route would almost certainly be to write the code to handle different size arrays automagically.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!