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

7 views (last 30 days)
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 Comment
Dyuman Joshi
Dyuman Joshi on 18 Aug 2023
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.

Sign in to comment.

Answers (1)

Shuba Nandini
Shuba Nandini on 29 Aug 2023
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

Categories

Find more on Line Plots in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!