How Can I Plot Multiple Curves in MATLAB with Variable Parameters?

In summary, you need to plot all the curves of the function v(t)=Vp*e^((a+c*t)/(1+b*t)), whille changing all the values of Vp,a,b,and c between 0 and 1, with step change of 0.1 and t varies from 0 to 100 with step change 1. The curves should be plotted in separate figures for full change f each of the mentioned constants.
  • #1
aleks_k
2
0
please help

hi there,

i've just started using MATLAB and need to do some task, but i don't know how, so maybe someone can help?

basicly, i need to plot all the curves of the function v(t)=Vp*e^((a+c*t)/(1+b*t)), whille changing all the values of Vp,a,b,and c between 0 and 1, with step change of 0.1 and t varies from 0 to 100 with step change 1. the curves should be plotted in separate figures for full change f each of the mentioned constants

so, i tried to do that with 4 nested cycles, changing the values of the constant...but it doesn't work

please help
 
Physics news on Phys.org
  • #2
Could you please post your code so far? (I'm not a Matlab user, but anyone who is and wants to help you will need to see how you are trying to do it in order to offer suggestions).
 
  • #3
aleks_k said:
hi there,

i've just started using MATLAB and need to do some task, but i don't know how, so maybe someone can help?

basicly, i need to plot all the curves of the function v(t)=Vp*e^((a+c*t)/(1+b*t)), whille changing all the values of Vp,a,b,and c between 0 and 1, with step change of 0.1 and t varies from 0 to 100 with step change 1. the curves should be plotted in separate figures for full change f each of the mentioned constants

so, i tried to do that with 4 nested cycles, changing the values of the constant...but it doesn't work

please help

Are you saying you want one plot of [v(t) vs. t] for each set of parameters (Vp,a,b,c) ? Did you try something like this? !Warning, it produces a lot of plots!
Code:
% test for pf guy
clear
t = [0:1:100];
Vp = [0:.5:1]; a = Vp; b = Vp; c = Vp;
for i = 1:length(Vp) % loop through Vp
    for j = 1:length(a) % loop through a
        for k = 1:length(b) % loop through b
            for l = 1:length(c)  % loop through c
                v=Vp(i).*exp((a(j)+c(l).*t)./(1+b(k).*t));
                vAll(:,i,j,k,l) = v;
                figure;plot(t,v); % create a new plot for each parameter set
                title(['Vp = ',num2str(Vp(i)), ', a = ', num2str(a(j)), ', b = ', num2str(b(k)), ', c = ', num2str(c(l))]);
            end
        end
    end
end
 
  • #4
well, i tried to produce plots outside each cycle, which was not that smart...i guess

however, i don't have MATLAB on this computer, so have to wait till tomorrow to try this thing..or send you my code so you can have a look at it..if you want

and yes, i have to plot all the curves for each set, but i wanted to organze them in gorups, let's say, all of the plots while vp is 1 and the other tree parameters change; than for vp 2...an so on...

so thanks a looooooooooot for this, i'll check it tomorrow

aleks
 
  • #5
Perhaps you can start by describing a little more clearly; how many total plots do you anticipate obtaining? What are your dependant and independent variables? How is your dependent variable changing and what is staying constant in each plot?

The more clearly you can state (understand) this part, the easier it will be to plot them.
 
  • #6
This seems like déjà vu.. Didn't you start a https://www.physicsforums.com/showthread.php?t=129159 in Electrical Engineering about the same question? We have some good replies there as well. Perhaps we can combine these into a single thread.
 
  • #7
The two threads have been merged. Note to aleks_k: One thread per topic please! :smile:
 

Related to How Can I Plot Multiple Curves in MATLAB with Variable Parameters?

1. How do I plot multiple data sets on one graph in MATLAB?

To plot multiple data sets on one graph in MATLAB, you can use the "hold on" command after each plot command. This will allow you to add additional plots to the same figure without clearing the previous one. Alternatively, you can use the "plotyy" function to create a graph with two y-axes, one for each data set.

2. How do I change the color or style of my plot in MATLAB?

You can change the color or style of your plot by adding additional arguments to the plot function. For example, to change the color to red, you can use the argument "r" or "red". To change the line style to dashed, you can use the argument "--" or "dashed". You can also use the "plot" function's Name-Value pair arguments to specify different colors and styles for each data set.

3. How do I add a title and axis labels to my plot in MATLAB?

To add a title and axis labels to your plot in MATLAB, you can use the "title", "xlabel", and "ylabel" functions. These functions allow you to specify the text and formatting for each element. You can also use the "legend" function to add a legend to your plot, labeling each data set.

4. How do I save my plot as an image in MATLAB?

To save your plot as an image in MATLAB, you can use the "saveas" function. This function allows you to specify the file type (such as .png or .jpg) and the desired filename. You can also use the "print" function to save a plot with specific formatting options, such as size and resolution.

5. How do I create a 3D plot in MATLAB?

To create a 3D plot in MATLAB, you can use the "plot3" function. This function works similar to the "plot" function, but allows you to specify a third dimension for your data. You can also use the "surf" function to create a surface plot, or the "mesh" function to create a wireframe plot.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
310
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
Back
Top