The code is correct, however I keep getting this error: Invalid color, marker, or line style.

% Parameters
f = 10; % Frequency in Hz
a = 1;
fs = 100; % Sampling rate in Hz
fst = 1; % Sampling time in seconds
ts = 1/100;
% Time axis
time = 0:ts:1;
% Complex sine wave
s = a* exp(j *2 * pi* f* t);
% Real and imaginary parts
real_s = real(s);
imag_s = imag(s);
% Plot
figure;
plot(t, real_s, 'r.*', t, imag_s, 'b-*');
xlabel('Time (s)');
ylabel('Amplitude');
title('10 Hz Signal Time-Domain Graph');

4 件のコメント

louis
louis 2024 年 4 月 12 日
I'm able to use other markers but not '.*' or '-*'.
plot(1:10,'-*')
plot(1:10,'.*')
Error using plot
Invalid color, marker, or line style.
Stephen23
Stephen23 2024 年 4 月 13 日
編集済み: Stephen23 2024 年 4 月 13 日
louis
louis 2024 年 4 月 14 日
Two marks isn't correct. Got it, thank you.

サインインしてコメントする。

 採用された回答

Fangjun Jiang
Fangjun Jiang 2024 年 4 月 12 日
編集済み: Fangjun Jiang 2024 年 4 月 12 日
See the possible marker symbol and line symbol
help plot
Various line types, plot symbols and colors may be obtained with
PLOT(X,Y,S) where S is a character string made from one element
from any or all the following 3 columns:
b blue . point - solid
g green o circle : dotted
r red x x-mark -. dashdot
c cyan + plus -- dashed
m magenta * star (none) no line
y yellow s square
k black d diamond
w white v triangle (down)
^ triangle (up)
< triangle (left)
> triangle (right)
p pentagram
h hexagram
For example, PLOT(X,Y,'c+:') plots a cyan dotted line with a plus
at each data point; PLOT(X,Y,'bd') plots blue diamond at each data
point but does not draw any line.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

製品

リリース

R2022b

タグ

質問済み:

2024 年 4 月 12 日

コメント済み:

2024 年 4 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by