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 Kommentare

priya
priya am 8 Sep. 2021
Sajid Afaque
Sajid Afaque am 8 Sep. 2021
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

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Sajid Afaque
Sajid Afaque am 8 Sep. 2021

0 Stimmen

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

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 8 Sep. 2021

1 Stimme

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)

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2017a

Tags

Gefragt:

am 8 Sep. 2021

Kommentiert:

am 8 Sep. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by