필터 지우기
필터 지우기

change variable name

조회 수: 3 (최근 30일)
Baba
Baba 2011년 11월 2일
I would like to be able to Change 'X7' to anything else in psdest and title. So for instance instead of manually chaning it in both places, I'd like to just have one place that I'd have to change this in.
Here is my code:
subplot(3,2,1)
Hs=spectrum.periodogram;
psdest = psd(Hs,X7,'Fs',Fs);
semilogx(psdest.Frequencies,10*log10(psdest.Data));
grid on;
xlabel('Frequency (Hz)')
ylabel('dB/Hz')
title('X7')

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 11월 2일
In one place, X7 is a variable. In the second place, 'X7' is a string. I am not sure what you try to do, but I don't see a real value for doing this. It is possible though,
Str='X7';
psdest = psd(Hs,eval(Str),'Fs',Fs);
title(Str);

추가 답변 (1개)

Walter Roberson
Walter Roberson 2011년 11월 2일
function psdplot(InputVar)
subplot(3,2,1)
Hs=spectrum.periodogram;
psdest = psd(Hs,InputVar,'Fs',Fs);
semilogx(psdest.Frequencies,10*log10(psdest.Data));
grid on;
xlabel('Frequency (Hz)')
ylabel('dB/Hz')
title(inputname(1))
Then call
psdplot(X7)

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by