matlab, how do i write a statement that will give me time on xaxis from y=0.3

前端 未结 5 1269
情书的邮戳
情书的邮戳 2020-12-11 22:34
x=[0:.01:10];
y=(x.^2).*(exp(-x));

plot(x,y), grid
y1=max(y);

xlabel(\'TIME\');
ylabel(\'CONCENTRATION IN BLOOD\');
title(\'CONCENTRATIN OF SUSTANCE IN BLOOD vs TI         


        
5条回答
  •  心在旅途
    2020-12-11 22:42

    In addition to the solutions already posted, I am adding other ways to solve the problem:

    f = @(x) (x.^2).*(exp(-x));             %# function handle
    y0 = 0.3;
    
    format long
    
    %# find root of function near s0
    x1 = fzero(@(x)f(x)-y0, 1)              %# find solution near x=1
    x2 = fzero(@(x)f(x)-y0, 3)              %# find solution near x=3
    
    %# find minimum of function in range [s1,s2]
    x1 = fminbnd(@(x)abs(f(x)-y0), 0, 2)    %# find solution in the range x∈[0,2]
    x2 = fminbnd(@(x)abs(f(x)-y0), 2, 4)    %# find solution in the range x∈[2,4]
    

提交回复
热议问题