필터 지우기
필터 지우기

plotting multiple coefficients of polynomial function

조회 수: 2 (최근 30일)
Shane Palmer
Shane Palmer 2020년 6월 20일
답변: Shane Palmer 2020년 6월 20일
Hello,
I have tried to follow the suggested examples for plotting multiple graphs on one figure of the same function with different coefficients.
I've been unsuccessful in my attempts. I am trying to model my function of omega and eta, but with multiple k values.
I started off trying to setup a for loop, but did not get that to work for me.
I tried to just define my k value multiple times and use the "hold on" command, but the graph just maintained the last value of k and excluded the previous k values.
I know I am missing something simple here, but I am not seeing it.
Here is my code:
syms omega__norm
k = 0.8;
eta__H = omega__norm*k.^2/(omega__norm.^2*(1-k.^2)+1)
fplot(omega__norm,eta__H,[10^-2 10^2])
set(gca,'Xscale','log')
hold off
Again, I would like setup k as a vector of values and plot all of the resulting graphs on a single figure.
Just not seeing how I need to do that properly.
Thank you for your help in advance!
  댓글 수: 1
Shane Palmer
Shane Palmer 2020년 6월 20일
Oh, just figured it out. I needed a for loop like this:
syms omega__norm
for k = 0.5:0.05:0.9
eta__H = omega__norm*k.^2/(omega__norm.^2*(1-k.^2)+1)
fplot(omega__norm,eta__H,[10^-2 10^2])
hold on
end
set(gca,'Xscale','log')
hold off
Thought that I had tried that, but it works now, sorry for the hassle.

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

채택된 답변

Shane Palmer
Shane Palmer 2020년 6월 20일
See comment above.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by