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

  • Context: MATLAB 
  • Thread starter Thread starter aleks_k
  • Start date Start date
  • Tags Tags
    Matlab Plotting
Click For Summary

Discussion Overview

The discussion revolves around plotting multiple curves in MATLAB for the function v(t)=Vp*e^((a+c*t)/(1+b*t)), with varying parameters Vp, a, b, and c. Participants explore how to implement this using nested loops and seek assistance with MATLAB coding, particularly in organizing the plots based on parameter values.

Discussion Character

  • Homework-related
  • Technical explanation
  • Exploratory

Main Points Raised

  • One participant requests help with plotting curves for a specific function while varying parameters between 0 and 1.
  • Another participant asks for the code that has been attempted to provide better assistance.
  • A participant suggests a method for plotting, using nested loops to iterate through parameter values and generate separate figures for each set of parameters.
  • One participant expresses uncertainty about their approach and indicates they need to wait to test the code on a different computer.
  • Another participant prompts for clarification on the total number of plots expected and the roles of dependent and independent variables in the context of the plots.
  • A participant notes a potential overlap with a previous thread on a similar topic, suggesting the threads might be combined.

Areas of Agreement / Disagreement

Participants are generally aligned in seeking to assist with the MATLAB plotting task, but there is no consensus on the best approach or clarity on the expected output.

Contextual Notes

There are unresolved questions regarding the organization of plots based on parameter values and the total number of plots anticipated. The discussion reflects varying levels of familiarity with MATLAB among participants.

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?

basically, 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 dependent 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 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
Replies
5
Views
3K
  • · Replies 9 ·
Replies
9
Views
5K
  • · Replies 4 ·
Replies
4
Views
2K