I am evaluating a problem that requires the resolution of a second order differential equation, which must be solved multiple times within a triple for loop. Here I leave you the code and the relevant function:
close all force
This a priori works correctly, but obviously it takes a while to compute everything, which I have not estimated. In case it was excessive, I would already try to play with the number of elements, especially the "time" array.
What I want to do with this is the following. First of all, in each iteration, I want to be able to see which integer (-1, 0, or 1) the final element of array "lx" and array "ly" is closest to. Once this is known, I would like to know if it is possible to assign to a matrix called, for example, "matrix", the following values depending on the combination of the final values of the arrays "lx" and "ly":
- If lx(end)=1 and ly(end)=0, then matrix(j,k)=0
- If lx(end)=0 and ly(end)=1, then matrix(j,k)=pi/2
- If lx(end)=-1 and ly(end)=0, then matrix(j,k)=pi
- If lx(end)=0 and ly(end)=-1, then matrix(j,k)=3*pi/2
It is not necessary to save this matrix when each loop in "i" ends, since what I want to do for each loop in "i" is to make a phase diagram through imagesc. I mean, I would like to plot something like this:
I don't know if the instruction will be correctly written to show the “Temperature” value in each iteration of “i” in both the title and the name of the saved file, let me know if it is misspelled, please. In this sense, the doubts I have regarding the graphs is (a) correctly put the title and the name of the file, (b) I do not know if by transmuting the matrix and putting ydir in the normal direction and axis xy it will be enough for the values to be conveniently labeled based on the array "amplitude_field", (c) imagine that when performing the analysis based on the last element of the arrays "lx" and "ly" no value of "matrix" is 3*pi/2, if this were the case, could its inclusion in the legend be ignored?, and (d) the ideal would be that after iteration in "Temperature", all traces of the previous phase diagram disappear (as the figure will have been saved, I don't need to keep it there), so there are no problems with u1, t1, posu1 on each iteration, right? How could that be pointed out to MatLab?
Thank you for your attention.