i want to plot "w" on x- axis and "a" on y- axis. I am not getting the plot. The code used is:
for w = -600:100:-100
a=sqrt(((1200./(w.^2))+10)/((300./(w.^2))+1));
end
plot(w, a)

댓글 수: 2

priya
priya 2021년 9월 8일
Sajid Afaque
Sajid Afaque 2021년 9월 8일
probably because you are overwriting a each time.
a stores last iteration value , hence you are plotting only single value of a.
store a as array, it will solve your issue

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

 채택된 답변

Sajid Afaque
Sajid Afaque 2021년 9월 8일

0 개 추천

count = 1;
for w = -600:100:-100
a(count) = sqrt((1200/w.^2)+10)/sqrt((300/w.^2)+1);
w_copy(count) = w
count = count+1;
end
figure
plot(w_copy,a)
both w and a are singilar value in your previous attempt, please use the above code it might solve your issue

추가 답변 (1개)

Walter Roberson
Walter Roberson 2021년 9월 8일

1 개 추천

wvals = -600:100:-100;
numw = length(wvals);
a = zeros(1,numw);
for widx = 1 : numw
w = wvals(widx);
a(widx) = sqrt((1200/w.^2)+10)/sqrt((300/w.^2)+1);
end
plot(wvals, a)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

릴리스

R2017a

태그

질문:

2021년 9월 8일

댓글:

2021년 9월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by