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')

3 ビュー (過去 30 日間)
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
Walter Roberson 2019 年 4 月 20 日
'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
  2 件のコメント
Lucy Raistrick
Lucy Raistrick 2019 年 4 月 20 日
That seems to have fixed an issue but now this error is appearing
>> pp01
Undefined function or variable 'Figure'.
Error in pp01 (line 35)
Figure 2
Walter Roberson
Walter Roberson 2019 年 4 月 20 日
MATLAB has been case sensitive for quite a while now. The graphics routines all start with lower case letters. figure and plot not Figure and Plot

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

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by