From: Fabian Eisa on
Dear Matlab community,

I am trying to find the maximum slope of some vectors (actually for 512x512 different vectors). Therefore I am doing first a polynomial fit to the values in the vector. Then I am doing a derivation, set some values in the equation and find the maximum.

syms u;
p = polyfit(time',Vektor,2);
Diff_1 = 2*p(1)*u + p(2);
max_Slope= max (subs(Diff_1, u, [0 2 4]));

If I do this for only a few values [0 2 4] everything works fine.
But if I use more values [0 2 4 6]

syms u;
p = polyfit(time',Vektor,2);
Diff_1 = 2*p(1)*u + p(2);
max_Slope= max (subs(Diff_1, u, [0 2 4 6]));

there comes the error message:
??? Error using ==> reshape
To RESHAPE the number of elements must not change.

It seems that this is a memory problem because I do the maximum slope calculation for 512x512 different vectors and save the values in a matrix but does anybody know why there is an error massage about reshape and does anybody has an idea how to solve the memory problem?
I would appreciate any help.
Thanks, Fab
From: us on
"Fabian Eisa" <Fabian.Eisa(a)imp.uni-erlangen.de> wrote in message <i0i3vk$2hu$1(a)fred.mathworks.com>...
> Dear Matlab community,
>
> I am trying to find the maximum slope of some vectors (actually for 512x512 different vectors). Therefore I am doing first a polynomial fit to the values in the vector. Then I am doing a derivation, set some values in the equation and find the maximum.
>
> syms u;
> p = polyfit(time',Vektor,2);
> Diff_1 = 2*p(1)*u + p(2);
> max_Slope= max (subs(Diff_1, u, [0 2 4]));
>
> If I do this for only a few values [0 2 4] everything works fine.
> But if I use more values [0 2 4 6]
>
> syms u;
> p = polyfit(time',Vektor,2);
> Diff_1 = 2*p(1)*u + p(2);
> max_Slope= max (subs(Diff_1, u, [0 2 4 6]));
>
> there comes the error message:
> ??? Error using ==> reshape
> To RESHAPE the number of elements must not change.
>
> It seems that this is a memory problem because I do the maximum slope calculation for 512x512 different vectors and save the values in a matrix but does anybody know why there is an error massage about reshape and does anybody has an idea how to solve the memory problem?
> I would appreciate any help.
> Thanks, Fab

this post is completely useless...
and it certainly is not a memory problem if one looks at the message...
show the whole story and error message...
this NG's motto is:
THINK - then POST...

us
From: Sadik on
Hi Fab,

I've tried to run the piece of code you sent and it worked fine. I don't think it is a memory issue.

Probably you have a script you are running that has more than those line into it and the error occurs elsewhere. Here is my suggestion to figure out what part causes the problem:

Before you run your script [i.e., the code which has these lines in it], type

dbstop if error

in the command window. Now, when it gives the reshape error, you will directly know where the error is occurring, it is going to stop right at the point of error. If it stops in reshape.m or any other place which is not your funciton, you can always use

dbup

to get to the level of your function. Please read the documentation about dbup, dbdown and dbstop.

Best.