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 a noob

  1. Jan 25, 2006 #1
    Hi there.. I am really noob to matlab i want to draw the following equation
    How can i draw this function?
    Can u help me?
    L takes values from 0 to 10km
    and Po=1watt
  2. jcsd
  3. Jan 26, 2006 #2


    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Well, start with the basics... do you know how to enter your data for L into Matlab? How about P(L)?
  4. Jan 27, 2006 #3
    Code (Text):
    Po = 1; % define Po
    a = 0.2; % define a
    L = 0:10/100:10 % make a vector L with 100 elements evenly spaced from 0 to 10

    %option 1, compute P(L) one element at a time
    for i = 1:length(L) %loop through all values of L
        P1(i) = Po*exp(-a*L(i));

    %option 2, compute all the values at once
    P2 = Po*exp(-a*L);

    figure;plot(L,P1) % Plot P vs L
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Similar Threads for Matlab help noob Date
MATLAB MATLab: Not enough inputs for nlinfit Nov 16, 2017
MATLAB Help needed to fix a matlab code Nov 8, 2017
New to Matlab, help with vectors Feb 20, 2016
Need help with integral Dec 23, 2015
MATLAB 2D diffusion equation, need help for matlab code. Nov 7, 2015