Plot a function which contains a variable parameter
    6 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    EldaEbrithil
 el 18 de Jun. de 2021
  
    
    
    
    
    Comentada: EldaEbrithil
 el 18 de Jun. de 2021
            Hi all
assuming to have a function like that:
function f=Myfun(t,a,b)
a=2*t;
f=t^2+a-b;
end
where b is a variable parameter [b(1)=0,b(2)=3,b(3)=7...]. How can I plot f for each values of b, in a certain time range, using a for loop?
Thank you very much
Reagards!!
0 comentarios
Respuesta aceptada
  KSSV
      
      
 el 18 de Jun. de 2021
        It is your home work....read about for loop and aray indexing in MATLAB. Given eblow a demo example. Extend this to your case.
a = [1 2 3] ; 
th = linspace(0,2*pi) ; 
X = zeros(length(a),length(th)) ;
for i = 1:length(a)
    X(i,:) = a(i)*sin(th) ;
end
plot(th,X)
1 comentario
Más respuestas (0)
Ver también
Categorías
				Más información sobre Loops and Conditional Statements 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!

