Can I make this kind of graph in matlab?

 Risposta accettata

Star Strider
Star Strider il 29 Lug 2014
I don’t know exactly what sort of format the data is that you’re plotting in those (it seems to be host response to an infectious agent of some sort) but you can likely reproduce plots like that with the image, colorbar and colormap functions. You will have to experiment with them to get the result you want.

6 Commenti

So, I've searched in the links and I think I it's a contour plot. However the paper I'm following doesn't indicate the data they've used to create the plot. So I guess I'm stuck. Thanks for your time.
My pleasure!
It looks like a simulation created by integrating a system of differential equations. The equations and the methods the authors used to integrate them should be in the paper or cited in the references. If they’re in another paper, you will have to get that paper as well. There are many functions in MATLAB that will integrate differential equations if you need to do that to replicate those data.
The contour function and its many friends (links in and at the end of that page) will work with the colormap and colorbar functions as well. When I created similar plots for my simulations, I used image, which is the reason I suggested it, but your data may differ from mine.
You're right. The paper I'm following involves a system of ODEs. I know how to solve the ODEs numerically, but I'm not sure on how to incorporate that with the contour function.
I apologise for the delay.
I would follow the paper’s lead on plotting the ODEs, since they probably describe what they did, how they got their results, and how they did their plots. They probably produced a matrix of results, solving their ODEs at different values of specific variables, generating a vector of solutions for each step in the variable, then plotting the resulting matrix. The variable they stepped through is probably ‘Treatment’ (‘Y’), using ‘Immune System’ (‘X’) as the ‘t’ in the ODE solver syntax, and plotting the result as the ‘Z’ value. (That’s a guess on my part. I may have it reversed.) It might be interesting for you to plot the matrix as a surface for your own benefit, even if the end result is a contour plot.
If they didn’t use MATLAB and its ODE solvers, don’t expect your results to exactly duplicate theirs. The MATLAB solvers seem to me to be superior to others currently available, but even different MATLAB ODE solvers don’t always agree.
I would also suggest using ode15s for ODEs, since it looks from the plot as though the ODEs are likely ‘stiff’ and may have some irregularities if not discontinuities.
Sorry for the late response.
The paper has only the results and it doesn't mention the software that was used. The system of ODEs is dX as in this question. If you care to look, the paper is here. I tried using 'Immune System' as the 't' in the ODE solver by replacing the original tspan with the domain of the figure. I could not get it to run (I'm not doing what you're asking maybe).
I think the biggest part of my confusion is plotting the varying parameters which come from my system dX. I can't find anything through a search with google that's remotely close to what I'm working with. When trying to plot solutions vs. parameter, I was told to use a for statement (what you see in the question I have linked). Now I'm trying to plot parameter vs. parameter, so should I have a nested for statement?
I apologize for not wanting to read and understand a 35-page paper just now, so I simply scanned it. (It is in an area of my expertise, and looks very interesting, but I have other things I need to read.) If you use an independent variable, for instance ‘I’ here, in place of time (perfectly legitimate), you can’t null it with ‘~’ in your ODE arguments. You also have to define it with respect to your ODE variables, for instance:
function dX = ode(I,X,T)
to tell your ODE to treat ‘I’ as your independent variable.
With respect to your for loop, I suggest you change it to:
treatment = 1e-4:1e-5:1e-3;
for k1 = 1:length(treatment)
[t(:,k1),X(:,:,k1)] = ode45(@ode, [0 4.5e4], [1e4 0 0], [] , treatment(k1));
end
I didn’t run this, so be sure ‘X’ is saved correctly, but since the outputs of the ODE functions are column variables, it should work. Taking the plot call out of your loop will speed things up considerably. Plot the appropriate variables (saved in t and X) outside the loop. If you define ‘t’ as something else (for instance ‘I’), you might want to define it with that variable name in the output of your ode45 call. Also, you didn’t say exactly how you were using it as tspan, but rather than a two-element range, I suggest you use a vector of defined values for ‘I’.
That should get you going. I’ll follow this until your code works, which it should since the paper’s authors got it to work.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Graphics Performance in Centro assistenza e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by