Why do I get "Error using matlab.graphics.primitive.Text/set The property name 'num2str(k)' is not a valid MATLAB identifier" in the 'title' line of my coding?
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
for k = 1:2:19
x = x + A*cos((pi/2)-k*2*pi*fc*t)/k;
y((k+1)/2,:) = x;
axis([0 0.05 -4 4]);
xlabel('Time (s)');
ylabel('Amplitude (V)');
title('Sum of ',num2str(k), 'th odd harmonics');
grid on;
end
0 Kommentare
Antworten (1)
Voss
am 13 Dez. 2021
Calling title like that sends three input arguments to title. This is not what you intend to do. You need to concatenate those three strings first, then send the result to title. Like this:
title(['Sum of ',num2str(k), 'th odd harmonics']);
2 Kommentare
Voss
am 14 Dez. 2021
You're welcome. If my answer solved the problem, please mark it as 'Accepted'. Thanks!
Siehe auch
Kategorien
Mehr zu Title finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!