How can I draw a 3D Free Energy Diagram from a text file which has 3 columns?

Apologies if the questions of this type have been already asked but I am a complete novice in MATLAB and am seeking help to draw a free energy diagram from a text file which looks like the following: (I have also attached the file) ------------------------------------------------------------------------------ 4.20766 0.13450 15.50000 4.21207 0.13450 15.50000 4.21647 0.13450 15.50000 4.22088 0.13450 14.20000 4.22528 0.13450 11.60000 4.22968 0.13450 12.90000 4.23409 0.13450 14.20000 4.23849 0.13450 15.50000 4.24289 0.13450 15.50000 ------------------------------------------------------------------------------------ There are 16000 rows and 3 columns. The first two are my parameters and third column is the free energy value. I want to plot this data and visualize as a 3D Free energy diagram. As I am novice, I might need a detailed help please.
Kind regards

 Respuesta aceptada

Dear Ankita, you can plot 3 columns of equal length as follows:
ID = fopen('filename.txt');
data = textscan(ID, '%f%f%f');
fclose(ID);
min(data{1})
max(data{1})
plot3(data{1}, data{2}, data{3}, '*-'), xlabel('x'), ylabel('y'), zlabel('Free energy')
I hope it helps. Good luck!

16 comentarios

Ankita
Ankita el 28 de Oct. de 2013
Editada: Ankita el 28 de Oct. de 2013
Hi, Thank you for your response. I tried doing this and the plot resulted in a line. I want to project it as a contour.
I am trying to plot a data like this:
Here is the code for desired plot:
ID = fopen('filename.txt');
data = textscan(ID, '%f%f%f');
fclose(ID);
x = data{1};
y = data{2};
z = data{3};
indminx = find(ismember(x, min(x)));
indmaxx = find(ismember(x, max(x)));
reshape_range = indmaxx(1) - indminx(1) + 1;
X = reshape(x, reshape_range, []);
Y = reshape(y, reshape_range, []);
Z = reshape(z, reshape_range, []);
surf(X, Y, Z), xlabel('RMSD to average'), ylabel('Radius to gyration'), zlabel('Gibbs free energy'), colorbar
I hope it is working now. Good luck!
Thank you very much indeed. The code works perfectly fine. I was wondering if you could help me out some more with this plot? I am sorry to bother you with silly questions but my ignorance with MATLAB doesn't help much. If I want to plot a 2D contour plot of this same data and then find the co-ordinates at each particular point preferably of the valleys/ low free energy valleys as obtained via the 3d plot? How can I go about that?
I really appreciate your kind help
You are welcome. You can see 2D contour plot of this data as follows:
contour3(X, Y, Z), xlabel('RMSD to average'), ylabel('Radius to gyration'), zlabel('Gibbs free energy'), colorbar, view([180 90])
You can find energy values and their respective 'x' and 'y' coordinates in sorted order as follow:
Matrix = [x, y, z];
Matrix = sortrows(Matrix, 3);
Is it what you needed?
Thank you for helping me out. The contour plot worked and I was wondering if I need to fill it like have it filled with color, do I need to change the color bar? Regarding the energy values, actually I am looking forward to something like Inspecting the FEL and finding where the Free Energy is minimal ('valleys'). Then I want to Select a few 'valleys' that would be representative. And if I can check which coordinates these correspond by right-clicking the 2D contour plot and selecting something which can "Get Coordinates" and then move mouse over the plot and it shows the coordinates at each particular point. These coordinates then I can trace back to find timestamps from my input file.
I know I am being quite specific and detailed but I am completely clueless to working around with MATLAB.
You are welcome. Contour plot just plot the boundary lines. You can see for more information: http://www.mathworks.de/de/help/matlab/ref/contour3.html
I basically don't know about FEL. You can use data cursor to see the energy values and their respective x and y coordinates on the contour plot. In order to trace back the timestamps you may need to use 2D interpolation. You can find information about it here: http://www.mathworks.de/de/help/matlab/ref/interp2.html
I hope it helps. Good luck!
You are welcome. Contour plot just plot the boundary lines. You can see for more information: http://www.mathworks.de/de/help/matlab/ref/contour3.html
I basically don't know about FEL. You can use data cursor to see the energy values and their respective x and y coordinates on the contour plot. In order to trace back the timestamps you may need to use 2D interpolation. You can find information about it here: http://www.mathworks.de/de/help/matlab/ref/interp2.html
I hope it helps. Good luck!
Thank you for the link. So, if I want to plot it as a colored 2D, I need to use something other than contour, right? Also, I think with the interpolation, I am not quite confident if that would work. All, I want to do is find the co-ordinates of the energy valleys as obtained in the landscape and then corresponding to that co-ordinates, I can try to find other things. I tried to use Data cursoe but it gives the error of callback trace. Have you got a feel for the reason behind this?
Maybe in this case 'meshc' will be helpful for you.
meshc(X, Y, Z), xlabel('RMSD to average'), ylabel('Radius to gyration'), zlabel('Gibbs free energy'), colorbar, view([0 270])
I used data cursor but I didn't get any error. See attachment for this. Good luck!
Hi,
I clicked on data cursor and then right clicked to make data tip but below are 2-3 of the list errors that I receive:
Error using handle.handle/set Invalid or deleted object.
Error in cameratoolbar (line 476)
Error in scribeclearmode (line 29) feval(func,s{2:end});
I personally never experienced such error. Maybe you can try to close and then reopen your MATLAB. Because at this point I can just give you suggestion not an exact solution because I am not getting any of such errors I checked. But if I will have a solution for this then I will come back to it
The error is persisting, I don't know why but nevertheless thank you very much indeed for such a massive and patient help with this plot. I really appreciate your promptness.
Kind regards,
I just wanted to say that I tried several times and now suddenly, my cursor seems to be working. I think it might be some accumulation of errors or just a hack or something. But thank you indeed with your help!
You are welcome. Yes it is also strange for me because I worked with cursor a lot but never encountered such errors. It is good that it is working now. Good luck with your work. Stay happy always
Thank you very much indeed and I just wanted to seek your permission to disturb you directly maybe when I need more help?
Yes you can ask me if I will be able then I will help you

Iniciar sesión para comentar.

Más respuestas (1)

Greetings
I used your reshape script for my test file. The following error is generated:
??? Error using ==> reshape Product of known dimensions, 1641, not divisible into total number of elements, 1681.
Error in ==> untitled at 10 X = reshape(x, reshape_range, []);
Can you please assist regarding this? I'm new to matlab. Thanks

Categorías

Preguntada:

el 28 de Oct. de 2013

Respondida:

el 16 de Dic. de 2013

Community Treasure Hunt

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

Start Hunting!

Translated by