color plotting error appearing only after one line and not appearing earlier

4 ビュー (過去 30 日間)
Em
Em 2023 年 8 月 18 日
回答済み: Shuba Nandini 2023 年 8 月 29 日
The second line of the fragment of code below throws an error. Does anyone have any idea why? I was able to plot just fine yesterday so I'm not sure what could be going on
plot(sulpholane9a(end-1000:20:end,1)*10^-6, sulpholane9a(end-1000:20:end,3)*10^9, '>','Color','b', 'LineWidth',1)%c(35,:))
hold on
plot(nitromethane11a(end-1000:20:end,1)*10^-6, nitromethane11a(end-1000:20:end,3)*10^9,'+','Color',c(45,:),'LineWidth',1)
hold on
plot(water2a(end-1000:20:end,1)*10^-6, water2a(end-1000:20:end,3)*10^9,'square','Color',c(65,:),'LineWidth',1)
Error using plot
Invalid RGB triplet. Specify a three-element vector of values between 0 and 1.
  1 件のコメント
Dyuman Joshi
Dyuman Joshi 2023 年 8 月 18 日
What is the range of the values in and size of the array c?
As the error states, the values must be a 3 element vector with values between 0 and 1.

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

回答 (1 件)

Shuba Nandini
Shuba Nandini 2023 年 8 月 29 日
Hello,
I understand you are getting color plotting error in your code using variable ‘c’.
The error message you're seeing "Invalid RGB triplet. Specify a three-element vector of values ranging from 0 and1" suggests that there might be a problem with how you specified the color in one of your plot commands.
  • If you prefer to use predefined MATLAB colors, you can simply use color names such, as 'b', 'r', 'g' without specifying the RGB values as you have specified it in this plot command.
plot(sulpholane9a(end-1000:20:end,1)*10^-6, sulpholane9a(end-1000:20:end,3)*10^9, '>','Color','b', 'LineWidth',1)
You can also refer to the follwoing thread to know how this error is resolved:
I hope this helps!
Regards,
Shuba Nandini

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by