Plot a function which contains a variable parameter
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
KSSV
2021-6-18
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)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!