MATLAB: Change variable name

variable

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')

Best Answer

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);