Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab help

  1. Aug 17, 2006 #1
    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
  2. jcsd
  3. Aug 17, 2006 #2


    User Avatar

    Staff: Mentor

    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).
  4. Aug 17, 2006 #3
    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 (Text):
    % test for pf guy
    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
                    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))]);
  5. Aug 17, 2006 #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

  6. Aug 20, 2006 #5


    User Avatar
    Science Advisor
    Homework Helper

    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.
  7. Aug 24, 2006 #6


    User Avatar
    Science Advisor
    Homework Helper

    This seems like déjà vu.. Didn't you start a thread in Electrical Engineering about the same question? We have some good replies there as well. Perhaps we can combine these into a single thread.
  8. Aug 24, 2006 #7

    Doc Al

    User Avatar

    Staff: Mentor

    The two threads have been merged. Note to aleks_k: One thread per topic please! :smile:
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook