Create a vector 't' and vector 'f' where 'f' is a mathematical function to plot.

1 visualización (últimos 30 días)
Create a vector 't' which consists of 100 numbers uniformly spread between 0.01 and 1. Also create a vector 'f' which includes the corresponding 100 values of the mathematical function t^(2) + 3t – 15. Plot 'f' versus 't'. This is what I have so far:
% Creating a vector 't' which consists of 100 numbers uniformly spread between 0.01 and 1
t=0.01+(1-0.01).*rand(1,100);
% Creating a vector 'f' which includes the corresponding 100 values of the mathematical function t^(2)+3t-15
f=t.^2+3*t-15
%add code
% Plotting 'f' versus 't'
figure(1),plot(f,t)

Respuesta aceptada

Jim Riggs
Jim Riggs el 5 de Mzo. de 2018
Editada: Jim Riggs el 5 de Mzo. de 2018
How about this:
t = 0:.01:1;
f = t.^2+3.*t-15;
figure;
plot(t,f,'b');
grid;
  7 comentarios
Jim Riggs
Jim Riggs el 5 de Mzo. de 2018
The instruction says you want a uniform spread from .01 to 1, so 1 is the highest value. The expression 1: .01 : 100 says start at one and go to 100 in steps of .01. This is not what you want. You want to start at 0 and go to 1 in steps of 0.01, this is expressed as:
0: 0.01 : 1

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by