"To RESHAPE the number of elements must not change" error during plot

Dear all,
I have a function (1x1 symfun) S4(t) with a variable of t. It's a very very long expression so I cannot write them here but it is a multi-exponential function.
Then I did:
t = 0:0.0000001:0.00002
y = S4(t)
plot(t,y)
However, I got "To RESHAPE the number of elements must not change". I have no idea where this came from because I have never used the command RESHAPE. Also, the first time around, when S4(t) was a slightly more compact function and rest of the script exactly the same, I did not have this issue.
I think the command "y = S4(t)" is the problem, but I don't see why it's not good. What am I doing wrong?
Thank you

15 comentarios

What is class and size of y? You must know it better is the output y have same size as t, so that they can be plotted. We can help you more only on knowing s4.
I don't know because the error stopped the script before y was defined anything. In the list of variables and symbols, while the other have like S4(t) 1x1 symfun, y had a blank.
BTW, S4(t) is VERY large but it looks like this: S4(t) = Aexp(B*t) + Cexp(D*t) - Eexp(-F*t) + ... for like over 70,000 characters.
Attach S4 function here...
Hayao
Hayao el 24 de Jun. de 2017
Editada: Hayao el 24 de Jun. de 2017
The file was too big to attach so I compressed it.
A 9MB .m file, I am looking for the first time in my life..... :| What for it is? I suspect something is wrong in understanding.
Hayao
Hayao el 24 de Jun. de 2017
Editada: Hayao el 24 de Jun. de 2017
No, there is nothing wrong in understanding the meaning of the equation itself. The equation itself is completely reasonable due to type of calculation this is for.
It's quite a technical thing, but I am trying to simulate luminescence decay profile in presence of concentration quenching in a luminescent material. Due to inhomogeneity of the doped luminescent center (maximum of 135), the concentration quenching center (maximum of 3), as well as the distribution of them, the equation is supposed to be multi-component.
In order to achieve a well simulated result, I did this calculation cycle for 1000 times, each with different distribution of luminescent center, as well as different distribution and number of quenching center. 1000 times should be enough for the equation to converge and account for the inhomogeneity. These 1000 equation (each of them are also multi-exponential due to multiple luminescent center taking effect of quenching center differently) are added together to form the final equation S4(t).
One calculation usually take about 20 hours to 40 hours, depending on the concentration of the luminescent center.
Jan
Jan el 24 de Jun. de 2017
Editada: Jan el 24 de Jun. de 2017
@Hayao: I do not understand, what you want to explain here. As KSSV has stated clearly, creating such huge M-files is a strange idea. It is unusual to store equations in this format. As long as the code does not define the type of "S(4)", the code must fail:
S4(t) =
(404934968861345816197309786212495*exp((3050546812132771*t)/89202980794122492566142873090593446023921664)) ... [left out the remaining MB...]
The blank line should cause an error message already. Then I do not think that the huge numbers are imported as you expect it. The strategy to create code in this way is flawed in every case.
The equation was derived during the script, so the equation itself is the output, not the script, hence the blank line. So it is NOT the .m file.
When I load your file in MATLAB it says NaN.
When I load your file in Maple it says unexpected end of file .
Could you save it as a .mat and attach that?
The file is in .txt format, and I only pasted S4(t) resulting from the calculation. I think it would be too big to open in MATLAB.
Do you want me to upload the entire .m script file? In that case, can I send it to you over e-mail? It's a data that I will be using for a paper so I do not want to paste it open to public.
Send me a message through my profile and I will reply and you can then attach on the return to that. Or just send me a link to a dropbox or googledrive or the like in the initial message.
Could you post the complete error message, please? The problem concerns reshape, but current we do not see this command in the posted code. In which line does the problem occur?
Hayao
Hayao el 25 de Jun. de 2017
Editada: Hayao el 25 de Jun. de 2017
Like I said, I never used the command reshape. But like KSSV said, the reshape command was probably automatically used to have the command "y = S4(t)" compatible with "t = 0:0.0000001:0.00002" command.
I only have the diary from the last few command record, but I've attached it. On the bottom, it has the error. Just so you know, the MATLAB is in Japanese because I am using a Japanese computer.
Ah, the partially contained message might mean, that this is a problem of sym/disp, so only the display in the command window is affected? Then try to supress this output using a semicolon.
As far as I know, with the command "y = S4(t)" after t being defined "0:0000001:0.00002", y should out put all S4(t) corresponding to the defined t. The output window did not even attempt this and instead returned an error. The diary also does not show this and returns an error before the output.
So I believe that it's not the output suppression problem. I think, as others have said, could be overflow or something. I've sent the entire script to Walter Roberson. So I guess I'll wait for what he can tell me.

Iniciar sesión para comentar.

 Respuesta aceptada

dpb
dpb el 24 de Jun. de 2017
"S4(t)" is symbolic and a (very) long character expression whereas "t" is double vector. plot is trying to turn them both into column vectors but they're not of commensurate lengths so it aborts.
You can try to convert the symbolic expression to numeric first but if it is so long it may not succeed; you may need to reformulate your problem to use numeric solution rather than explicit symbolic. Doing so would probably also reduce your calculation time by orders of magnitude.

2 comentarios

Hayao
Hayao el 24 de Jun. de 2017
Editada: Hayao el 24 de Jun. de 2017
I am a little bit reluctant in using numeric solution. I am using system of 135 linear differential equation to solve this under matrix eigenvalue problem formulation. Since I am changing the "concentration of luminescent center" to compare the result, the comparison should be of small difference, so I am afraid that I lose the precision required for the comparison when I used numeric solution.
Also, I don't know how to obtain numeric solution to such large system of differential equation.
Do you think vpa would work?
"Do you think vpa would work?"
No, not really, I don't. What have you got to lose to try, however, you've reached/exceeded the limits of practicality and crashed symbolics this way.
I suspect you're going to have to reformulate the solution technique rather than being able to brute-force a direct solution.

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 24 de Jun. de 2017

Comentada:

el 25 de Jun. de 2017

Community Treasure Hunt

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

Start Hunting!

Translated by