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

  • Thread starter Thread starter aleks_k
  • Start date Start date
  • Tags Tags
    Matlab Plotting
AI Thread Summary
A user new to MATLAB seeks assistance with plotting the function v(t) = Vp * e^((a + c*t)/(1 + b*t)), varying the parameters Vp, a, b, and c from 0 to 1 in increments of 0.1, while t ranges from 0 to 100. The user attempted to implement this using four nested loops but encountered issues. A suggestion was made to use a similar structure to generate separate plots for each parameter set, emphasizing the need to clarify the organization of plots based on constant and varying parameters. The user acknowledged the need for better organization of plots and plans to test the provided code later. Additionally, there was a reminder to keep discussions focused on a single topic to streamline assistance.
aleks_k
Messages
2
Reaction score
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
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).
 
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
 
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
 
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.
 
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.
 
The two threads have been merged. Note to aleks_k: One thread per topic please! :smile:
 

Similar threads

Replies
4
Views
4K
Replies
2
Views
3K
Replies
1
Views
2K
Replies
3
Views
2K
Replies
9
Views
5K
Replies
4
Views
1K
Back
Top