How to include variables in an expression while plotting?
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
For example
Nth=10^(15+20log10(f))*Nthoff
if i have to plot this expression and the 'Nthoff' value is unknown! how to plot expressions like this if few variable values in the expressions are unknown.
댓글 수: 0
답변 (1개)
Rik
2017년 2월 15일
In this case, you don't really need to know Nthoff, as it is only a factor, so you can plot this while setting Nthoff=1;
Usually, you would have a range of values that a parameter is expected to have, then you could use either a for-loop to plot a few manually chosen different values, or you can use a vectorized (in this case a matrix-ized) solution. Because there is no way for Matlab to predict the behavior of your function without the range of possible values, it will not be able to plot the shape of the general solution (except in cases like yours).
f=linspace(0,7,130)';%make sure it is a col-vector
Nthoff=1:4;%make sure it is a row-vector
Nth=repmat(10.^(15+20*log10(f)),1,length(Nthoff)).*repmat(Nthoff,length(f),1);
plot(f,Nth)
Or in a loop:
f=linspace(0,7,130)';%make sure it is a col-vector
Nthoff=1:4;%make sure it is a row-vector
for n=Nthoff
Nth=10.^(15+20*log10(f))*n;
plot(f,Nth),hold on
end
댓글 수: 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!