Error in color linetype argument

Please help me, I am trying to run this code: function perf(T,logplot) if (nargin< 2) logplot = 0; end colors = ['m''b''r''g''c''k''y']; lines = ['-''-''-.''--']; markers = ['x''x'...

Chieu Nguyen

Please help me, I am trying to run this code:

function perf(T,logplot)

if (nargin< 2) logplot = 0; end

colors = [‘m»b»r»g»c»k»y’];

lines = [‘-»-»-.»—‘];

markers = [‘x»x»x»x»v»^»o’];

[np,ns] = size(T);

minperf = min(T,[],2);

r = zeros(np,ns);

for p = 1: np

r(p,:) = T(p,:)/minperf(p);

end

if (logplot) r = log2(r); end

max_ratio = max(max(r));

r(find(isnan(r))) = 2*max_ratio;

r = sort(r);

clf;

for s = 1: ns

[xs,ys] = stairs(r(:,s),[1:np]/np);

option = [‘-‘ colors(s) markers(s) ];

plot(xs,ys,option,‘MarkerSize’,3);

hold on;

end

axis([ 0.1 1.1*max_ratio 0 1 ]);

When I running, it appears error:

perf(T,2)

Error using plot Error in color/linetype argument.

Error in perf (line 20) plot(xs,ys,option,’MarkerSize’,3);

If someone knows the answer, please help me.

Accepted Answer

Walter Roberson

lines = [‘-»-»-.»—‘];

creates a character vector that contains -‘-‘-.’—

You need to learn how to use cell arrays of character vectors.


More Answers (2)

Steven Lord

Depending on the release you’re using, I recommend using string arrays instead.

colors = [«m», «b», «r», «g», «c», «k», «y»];

lines = [«-«, «-«, «-.», «—«];

markers = [«x», «x», «x», «x», «v», «^», «o»];

plot(1:10, 1:10, colors(3)+lines(4)+markers(5))

Note that this is different from concatenating the strings together using [], which will not work.

doesNotWork = plot(1:10, 1:10, [colors(3),lines(4),markers(5)])

Using + to combine the three scalar string arrays makes a new scalar string whose contents are the contents of the shorter strings concatenated, while using [] makes a larger string array each element of which is one of the original strings. The two string arrays works and doesNotWork defined below look different and have different sizes.

works = colors(3)+lines(4)+markers(5)

doesNotWork = [colors(3), lines(4), markers(5)]

whos works doesNotWork


kaushik gupta

clc;

clf;

close all;

clear all;

x1=(‘Enter the sequence x:’);

g=x1(end:-1:1);

i=length(x1);

j=length(g);

cov=zeros(1,i+j-1);

for k=i;

for i=j;

cov(k+i-1)=cov(k+i-1)+x1(k)*g(i);

end;

end;

m=0:length(x1)-1;

subplot(2,1,1);

stem(m,x1);

grid on;

axis([-1 length(cov) min(cov)-2 max(cov)+2]);

xlabel(‘…’);

ylabel(‘original sequence’);

title(‘Autocorrelation’);

See Also

Categories

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Содержание

  1. error in color/linetype argument
  2. Direct link to this question
  3. Direct link to this question
  4. Answers (1)
  5. Direct link to this answer
  6. Direct link to this answer
  7. See Also
  8. Categories
  9. Community Treasure Hunt
  10. How to Get Best Site Performance
  11. Americas
  12. Europe
  13. Asia Pacific
  14. error in color/linetype argument
  15. Direct link to this question
  16. Direct link to this question
  17. Answers (1)
  18. Direct link to this answer
  19. Direct link to this answer
  20. See Also
  21. Categories
  22. Community Treasure Hunt
  23. How to Get Best Site Performance
  24. Americas
  25. Europe
  26. Asia Pacific
  27. Scatter Error in color/linetype argument when using ‘|’ marker
  28. Direct link to this question
  29. Direct link to this question
  30. Accepted Answer
  31. Direct link to this answer
  32. Direct link to this answer
  33. Direct link to this comment
  34. Direct link to this comment
  35. More Answers (0)
  36. See Also
  37. Categories
  38. Community Treasure Hunt
  39. How to Get Best Site Performance
  40. Americas
  41. Europe
  42. Asia Pacific
  43. User defined color/linetype property
  44. Direct link to this question
  45. Direct link to this question
  46. Accepted Answer
  47. Direct link to this answer
  48. Direct link to this answer
  49. Direct link to this comment
  50. Direct link to this comment
  51. More Answers (0)
  52. See Also
  53. Categories
  54. Community Treasure Hunt
  55. How to Get Best Site Performance
  56. Americas
  57. Europe
  58. Asia Pacific
  59. User defined color/linetype property
  60. Direct link to this question
  61. Direct link to this question
  62. Accepted Answer
  63. Direct link to this answer
  64. Direct link to this answer
  65. Direct link to this comment
  66. Direct link to this comment
  67. More Answers (0)
  68. See Also
  69. Categories
  70. Community Treasure Hunt
  71. How to Get Best Site Performance
  72. Americas
  73. Europe
  74. Asia Pacific

error in color/linetype argument

Direct link to this question

Direct link to this question

0 Comments

Answers (1)

Direct link to this answer

Direct link to this answer

0 Comments

See Also

Categories

Community Treasure Hunt

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

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

Читайте также:  Geovision gv bl110d прошивка

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

error in color/linetype argument

Direct link to this question

Direct link to this question

0 Comments

Answers (1)

Direct link to this answer

Direct link to this answer

0 Comments

See Also

Categories

Community Treasure Hunt

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

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Scatter Error in color/linetype argument when using ‘|’ marker

Direct link to this question

Direct link to this question

0 Comments

Accepted Answer

Direct link to this answer

Direct link to this answer

1 Comment

Direct link to this comment

Direct link to this comment

More Answers (0)

See Also

Categories

Community Treasure Hunt

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

Читайте также:  Sr 01a e258603 прошивка

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

User defined color/linetype property

Direct link to this question

Direct link to this question

0 Comments

Accepted Answer

Direct link to this answer

Direct link to this answer

1 Comment

Direct link to this comment

Direct link to this comment

More Answers (0)

See Also

Categories

Community Treasure Hunt

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

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

Читайте также:  Sd mdvr sw 0001a прошивка

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

User defined color/linetype property

Direct link to this question

Direct link to this question

0 Comments

Accepted Answer

Direct link to this answer

Direct link to this answer

1 Comment

Direct link to this comment

Direct link to this comment

More Answers (0)

See Also

Categories

Community Treasure Hunt

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

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.
  • Forums

  • Mathematics

  • MATLAB, Maple, Mathematica, LaTeX

Matlab’s plot command

  • MATLAB

  • Thread starter
    MathematicalPhysicist

  • Start date
    Nov 30, 2017

  • Nov 30, 2017
  • #1
I am using Matlab’s 2017Rb academic license.

And while trying to operate the following sequence of commands:

x = linspace(0,2*pi,1000);
y = sin(2*x);
plot(x,y,'k−','linew',2); hold on;

I get the following warning:

Error using plot
Error in color/linetype argument.

What seems to be wrong in the above code?

Thanks.

Answers and Replies

  • Nov 30, 2017
  • #2

  • Nov 30, 2017
  • #3
So the error is in ‘k-‘, how it should be?
‘-k’, yes now it works.

  • Nov 30, 2017
  • #4
So the error is in ‘k-‘, how it should be?
‘-k’, yes now it works.

But… ‘-k’ make the same as ‘k’ I think…

  • Nov 30, 2017
  • #5
So the error is in ‘k-‘, how it should be?
‘-k’, yes now it works.

Interesting. The documentation says that the order of the symbols doesn’t matter. So this is either a bug or there is something else going on.

  • Dec 1, 2017
  • #6
Interesting. The documentation says that the order of the symbols doesn’t matter. So this is either a bug or there is something else going on.

Did you try it in your machine?

I have Ubuntu 16.04 as the OS in this computer.

  • Dec 1, 2017
  • #7
But… ‘-k’ make the same as ‘k’ I think…

Yes, it works as well.

  • Dec 1, 2017
  • #8

And… Why were you trying to plot ‘k-‘?

  • Dec 1, 2017
  • #9
And… Why were you trying to plot ‘k-‘?

I copy-paste this snippet of code from some lecture notes I am reading.

So there I had this ‘k-‘.

  • Dec 1, 2017
  • #10
Did you try it in your machine?

I have Ubuntu 16.04 as the OS in this computer.

I’m retired and no longer have access to MATLAB. I’m thinking about buying it just for these occasions.

  • Dec 7, 2017
  • #11
It’s not a bug. And the order doesn’t matter. The problem is you don’t have a dash in there. It’s some character that looks like a dash but isn’t. When I paste in your code it shows the error message

Error using plot
Error in color/linetype argument.
Error in test1 (line 3)
plot(x,y,’k?’,’linew’,2);

See the question mark indicating it doesn’t know what that character is? If you get rid of that «dash» and replace it with a real dash (minus sign), it will work perfectly fine.

  • Dec 7, 2017
  • #12
It’s not a bug. And the order doesn’t matter. The problem is you don’t have a dash in there. It’s some character that looks like a dash but isn’t. When I paste in your code it shows the error message

Error using plot
Error in color/linetype argument.
Error in test1 (line 3)
plot(x,y,’k?’,’linew’,2);

See the question mark indicating it doesn’t know what that character is? If you get rid of that «dash» and replace it with a real dash (minus sign), it will work perfectly fine.

Good catch! This is one of the frustrating things about copying and pasting text — they can have characters and do other things you don’t want. I like to paste into a programmer editor that I can control, like vim, just to be sure that the text is exactly what I wanted. I often have to replace things that I don’t want in code. Then I copy the vim text and paste that into the target code.

Suggested for: Matlab’s plot command

  • Last Post
  • Aug 26, 2021
  • Last Post
  • Apr 21, 2022
  • Last Post
  • Sep 17, 2022
  • Last Post
  • Apr 17, 2021
  • Last Post
  • Apr 26, 2021
  • Last Post
  • May 18, 2022
  • Last Post
  • Jan 15, 2019
  • Last Post
  • Jun 1, 2020
  • Last Post
  • Oct 27, 2021
  • Last Post
  • Mar 27, 2019
  • Forums

  • Mathematics

  • MATLAB, Maple, Mathematica, LaTeX

error in color/linetype argument

Direct link to this question

Direct link to this question

0 Comments

Answers (1)

Direct link to this answer

Direct link to this answer

0 Comments

See Also

Categories

Community Treasure Hunt

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

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

error in color/linetype argument

Direct link to this question

Direct link to this question

0 Comments

Answers (1)

Direct link to this answer

Direct link to this answer

0 Comments

See Also

Categories

Community Treasure Hunt

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

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

When running code it returns >> pp01 Error using plot Error in color/linetype argument. Error in pp01 (line 33) plot(t(:),​z(:,1),’W’​,t(:),z(:,​2),’F’)

Direct link to this question

Direct link to this question

0 Comments

Answers (1)

Direct link to this answer

Direct link to this answer

  • b: blue
  • c: cyan
  • d: diamond marker
  • g: green
  • h: hexagon marker
  • k: black
  • m: magenta
  • o: circle marker
  • p: pentagram marker
  • r: red
  • s: square marker
  • v: down triangle marker
  • w: white
  • x: x marker
  • y: yellow
  • * : * marker
  • +: + marker
  • . : dot marker
  • ^: upward triangle marker
  • >: right triangle marker
  • — and : are used for line styles
2 Comments

Direct link to this comment

Direct link to this comment

Direct link to this comment

Direct link to this comment

See Also

Categories

Community Treasure Hunt

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

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Error in color/linetype argument when using errorbar

Direct link to this question

Direct link to this question

0 Comments

Answers (1)

Direct link to this answer

Direct link to this answer

2 Comments

Direct link to this comment

Direct link to this comment

Direct link to this comment

Direct link to this comment

See Also

Categories

Community Treasure Hunt

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

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文 Chinese
    • English
  • 日本 Japanese (日本語)
  • 한국 Korean (한국어)

Accelerating the pace of engineering and science

MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Источник

Matlab’s plot command

I am using Matlab’s 2017Rb academic license.

And while trying to operate the following sequence of commands:

What seems to be wrong in the above code?

Answers and Replies

Check this Matlab plot command page. The examples show some args:

Did you try it in your machine?

I have Ubuntu 16.04 as the OS in this computer.

I copy-paste this snippet of code from some lecture notes I am reading.

So there I had this ‘k-‘.

Did you try it in your machine?

I have Ubuntu 16.04 as the OS in this computer.

It’s not a bug. And the order doesn’t matter. The problem is you don’t have a dash in there. It’s some character that looks like a dash but isn’t. When I paste in your code it shows the error message

Error using plot
Error in color/linetype argument.
Error in test1 (line 3)
plot(x,y,’k?’,’linew’,2);

See the question mark indicating it doesn’t know what that character is? If you get rid of that «dash» and replace it with a real dash (minus sign), it will work perfectly fine.

It’s not a bug. And the order doesn’t matter. The problem is you don’t have a dash in there. It’s some character that looks like a dash but isn’t. When I paste in your code it shows the error message

Error using plot
Error in color/linetype argument.
Error in test1 (line 3)
plot(x,y,’k?’,’linew’,2);

See the question mark indicating it doesn’t know what that character is? If you get rid of that «dash» and replace it with a real dash (minus sign), it will work perfectly fine.

Источник

When running code it returns >> pp01 Error using plot Error in color/linetype argument. Error in pp01 (line 33) plot(t(:),​z(:,1),’W’​,t(:),z(:,​2),’F’)

Lucy Raistrick

function pp01

clear

global As Qt g A c

As=15;

Qt=10;

g=9.81;

A=(121/64)*pi;

c=0.02;

z1_initial=10;

z2_initial=25;

N=1000;

h=0.5;

t=zeros(N,1);

z=zeros(N,2);

t(1)=0;

z(1,1)=z1_initial;

z(1,2)=z2_initial;

for n=1:N-1

t(n+1)=t(n)+h;

z(n+1,:)=z(n,:)+h*f(t(n),z(n,:));

z(n+1,:)=z(n,:)+0.5*h*(f(t(n),z(n,:))+f(t(n+1),z(n+1,:)));

end

%plot(t(:),z(:,1),’W’,t(:),z(:,2),’F’)

Figure 2

Plot(z(:,1),z(:,2))

[t,z];

return

function dzdt=f(~,z)

global As Qt g A c

%dzdt(1)=z(2);

%dzdt(2)=-z(1);

dzdt(1)=(1/As)*(z(2)-Qt);

dzdt(2)=-g*(A/2)*(z(1)+(c*abs(z(2))*z(2)));

return


回答(1 个)

Walter Roberson

‘W’ is valid as a code for White but ‘F’ is not a color abbreviation and is not a marker shape code. Valid codes are

  • b: blue
  • c: cyan
  • d: diamond marker
  • g: green
  • h: hexagon marker
  • k: black
  • m: magenta
  • o: circle marker
  • p: pentagram marker
  • r: red
  • s: square marker
  • v: down triangle marker
  • w: white
  • x: x marker
  • y: yellow
  • *: * marker
  • +: + marker
  • . : dot marker
  • ^: upward triangle marker
  • <: left triangle marker
  • >: right triangle marker
  • — and : are used for line styles

另请参阅

类别

Community Treasure Hunt

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

Start Hunting!

发生错误

由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。

Translated by Microsoft

Hi,

I would like to plot several lines together using plot3, each line having
its own color specification. I know that this can somehow be done using the
syntax

plot3(Xcoords, Ycoords, Zcoords, Linespecs)

in which the above four arguments are vectors or matrices, but my problem
is that I do not know how to construct the Linespecs matrix/vector.

For example,

plot3([1,3; 1,3], [2,4; 2,4], [0,0; 1,1])

is OK, bit if I try

plot3([1,3; 1,3], [2,4; 2,4], [0,0; 1,1], [[‘Color’,[1,0,0]],
[‘Color’,[1,0,1]]])

I get the error message «Error in color/linetype argument». What is
the
correct way of constructing the matrix/vector of line specifications please?

Many thanks,

Richard

——————————-
Richard Dybowski, 143 Village Way, Pinner, Middlesex HA5 5AA, UK
Tel (mobile): 079 76 25 00 92

Reply by September 4, 20012001-09-04

hello,

one way of doing this is the following.
ues

h = plot3([1,3; 1,3], [2,4; 2,4], [0,0; 1,1]);

h is now a 2 by 1 vector containing hadles to the line objects, you can now
type

set(h,’color’,[0 1 0])

or if you want to change each line seperatly
set(h(1),’color’,[0 1 0]) ,etc.

get(h(1))
shows all the parameters of the object h(1) (the line in this case) that
can be varied.

Hope this helps

Mark Hunter.
At 15:24 4/09/2001 +0100, Richard Dybowski wrote:
>Hi,
>
>I would like to plot several lines together using plot3, each line having
>its own color specification. I know that this can somehow be done using
the
>syntax
>
>plot3(Xcoords, Ycoords, Zcoords, Linespecs)
>
>in which the above four arguments are vectors or matrices, but my problem
>is that I do not know how to construct the Linespecs matrix/vector.
>
>For example,
>
>plot3([1,3; 1,3], [2,4; 2,4], [0,0; 1,1])
>
>is OK, bit if I try
>
>plot3([1,3; 1,3], [2,4; 2,4], [0,0; 1,1], [[‘Color’,[1,0,0]],
>[‘Color’,[1,0,1]]])
>
>I get the error message «Error in color/linetype argument». What
is the
>correct way of constructing the matrix/vector of line specifications
please?
>
>Many thanks,
>
>Richard
>
>——————————-
>Richard Dybowski, 143 Village Way, Pinner, Middlesex HA5 5AA, UK
>Tel (mobile): 079 76 25 00 92
>
>
>_____________________________________
>Note: If you do a simple «reply» with your email client, only the
author
>of this message will receive your answer. You need to do a «reply
all» if
>you want your answer to be distributed to the entire group.
>
>_____________________________________
>About this discussion group:
>
>To Join:
>
>To Post:
>
>To Leave:
>
>Archives: http://www.yahoogroups.com/group/matlab
>
>More DSP-Related Groups: http://www.dsprelated.com/groups.php3
>
>»>http://docs.yahoo.com/info/terms/

INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Thanks. We have received your request and will respond promptly.

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!

  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It’s Free!

*Eng-Tips’s functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Problem with plotting with string of different color names

Problem with plotting with string of different color names

(OP)

18 Dec 02 04:22

Hello,

I am having problem with using different colors base on the the various cmd in the for loop. I apply the suggested solution provided in one of the past threads but I am not able to get the result. I don’t understand what the error message is reporting. Can someone help me? Many Thanks in advance.

C=[‘r.’ ‘g.’ ‘b.’ ‘c.’];
for ht = 0:(num-1)
  for cmd = 1:4,
        idx = (find(new_h == ht & new_cmd == cmd));
        [r] = ind2sub(idx, [idx]);
        chs = [new_cmd, new_c, new_s];
        cmdgroup = chs([r],:);
        c = cmdgroup(:,2);
        s = cmdgroup(:,3);
        cmd = cmdgroup(:,1);
        plot(c, s, C(cmd));
        axis ([-5000 40000 -100 900]);
        hold on;
  end;
end;

======================================================
Error message :

??? Error in color/linetype argument

On line 49  ==>     plot(c, s, C(cmd));

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds

Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now

Design for Additive Manufacturing (DfAM)

Examine how the principles of DfAM upend many of the long-standing rules around manufacturability — allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now

Industry Perspective: Education and Metal 3D Printing

Metal 3D printing has rapidly emerged as a key technology in modern design and manufacturing, so it’s critical educational institutions include it in their curricula to avoid leaving students at a disadvantage as they enter the workforce. Download Now

Taking Control of Engineering Documents

This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Join Eng-Tips® Today!

Join your peers on the Internet’s largest technical engineering professional community.
It’s easy to join and it’s free.

Here’s Why Members Love Eng-Tips Forums:

  • Eng-Tips ForumsTalk To Other Members
  • Notification Of Responses To Questions
  • Favorite Forums One Click Access
  • Keyword Search Of All Posts, And More…

Register now while it’s still free!

Already a member? Close this window and log in.

Join Us             Close

Понравилась статья? Поделить с друзьями:
  • Error in closing in the unzipfile
  • Error in class librarylwjglopenal
  • Error in class codecjorbis
  • Error in child compilations use stats children true resp stats children for more details
  • Error in chartodate x текстовая строка не относится к стандартному однозначному формату