Multiple input values for same function and plot them?

조회 수: 56 (최근 30일)
Gaetano Dona-Jehan
Gaetano Dona-Jehan 2019년 11월 25일
댓글: Adam Danz 2019년 11월 28일
Hello,
I was wondering if there was a quick clean and easy way to make a function input multiple values of x, such as 0, .25 ,.5, .75, 1 and then plot these five curves out on the same plot. I know how to do it manualy by create 5 different functions and naming them slightly differently, but I was wondering if there was a quicker/cleaner way of doing it?
  댓글 수: 4
Hedayat
Hedayat 2019년 11월 28일
You can use plot in one statement
plot(X1,Y1,...,Xn,Yn) plots multiple X, Y pairs using the same axes for all lines.
KSSV
KSSV 2019년 11월 28일
MAke the input as amtrix and plot in one strectch.

댓글을 달려면 로그인하십시오.

답변 (1개)

KSSV
KSSV 2019년 11월 28일
A = [10 20 30 405 50] ;
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)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by