Basic Octave Operations

GNU Octave, version 6.4.0
Copyright (C) 2021 The Octave Project Developers.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-w64-mingw32".

Additional information about Octave is available at https://www.octave.org.

Please contribute if you find this software useful.
For more information, visit https://www.octave.org/get-involved.html

Read https://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.
octave:17> PS1('>> '); %切换输入界面的显示
>>

>> pwd
ans = C:\CodeLi\OctaveLi
>> ls
 Volume in drive C is OS
 Volume Serial Number is 6C71-6303

 Directory of C:\CodeLi\OctaveLi

[.]                    [..]                   [MLofAndrew-Ng-master] octave.pdf
               1 File(s)      4,597,433 bytes
               3 Dir(s)  257,943,969,792 bytes free
>> who
Variables visible from the current scope:

ans

>> A =[1 2;3 4; 5 6]
A =

   1   2
   3   4
   5   6

>> A(3,2)
ans = 6
>> A(2,:)
ans =

   3   4

>> A(:,2)
ans =

   2
   4
   6

>> A([1 3],:)
ans =

   1   2
   5   6

>> A
A =

   1   2
   3   4
   5   6

>> A(:,2) = [10; 11; 12]
A =

    1   10
    3   11
    5   12

>> A=[A,[100;110;120]]
A =

     1    10   100
     3    11   110
     5    12   120

>> size(A)
ans =

   3   3

>> t=[0:0.01;0.98];
>> t
t =

        0
   0.9800

>> t=[0:0.01:0.98];
>> t
t =

 Columns 1 through 13:

        0   0.0100   0.0200   0.0300   0.0400   0.0500   0.0600   0.0700   0.0800   0.0900   0.1000   0.1100   0.1200

 Columns 14 through 26:

   0.1300   0.1400   0.1500   0.1600   0.1700   0.1800   0.1900   0.2000   0.2100   0.2200   0.2300   0.2400   0.2500

 Columns 27 through 39:

   0.2600   0.2700   0.2800   0.2900   0.3000   0.3100   0.3200   0.3300   0.3400   0.3500   0.3600   0.3700   0.3800

 Columns 40 through 52:

   0.3900   0.4000   0.4100   0.4200   0.4300   0.4400   0.4500   0.4600   0.4700   0.4800   0.4900   0.5000   0.5100

 Columns 53 through 65:

   0.5200   0.5300   0.5400   0.5500   0.5600   0.5700   0.5800   0.5900   0.6000   0.6100   0.6200   0.6300   0.6400

 Columns 66 through 78:

   0.6500   0.6600   0.6700   0.6800   0.6900   0.7000   0.7100   0.7200   0.7300   0.7400   0.7500   0.7600   0.7700

 Columns 79 through 91:

   0.7800   0.7900   0.8000   0.8100   0.8200   0.8300   0.8400   0.8500   0.8600   0.8700   0.8800   0.8900   0.9000

 Columns 92 through 99:

   0.9100   0.9200   0.9300   0.9400   0.9500   0.9600   0.9700   0.9800

>> y=sin(2*pi*4*t);
>> plot(t,y);
>> y2 = cos(2*pi*4*t);
>> plot(t,y2)
>> plot(t,y2);
>> plot(t,y);
>> hold on;
>> plot(t,y2,'r');
>> xlabel('time')
>> ylabel('value')
>> legend('sin','cos')
>> title('myplot')
>> cd 'C:\user\wenpeng
error: parse error:

  syntax error

>>> cd 'C:\user\wenpeng
                      ^
>> cd 'C:\user\wenpeng\Desktop'; print -dpng 'myplot.png
error: parse error:

  syntax error

>>> cd 'C:\user\wenpeng\Desktop'; print -dpng 'myplot.png
                                                        ^
>> cd 'C:\user\wenpeng\Desktop'; print -dpng 'myplot.png'
error: C:\user\wenpeng\Desktop: No such file or directory
>> cd 'C:\users\wenpeng\Desktop'; print -dpng 'myplot.png'
>> close
>> figure(1);plot(t,y);
>> figure(1);plot(t,y2);
>> subplot(1,2,1);
>> plot(t,y)
>> subplot(1,2,2);
>> plot(t,y2);
>> axis([0.5 1 -1 1])
>> help axis
'axis' is a function from the file C:\Program Files\GNU Octave\Octave-6.4.0\mingw64\share\octave\6.4.0\m\plot\appearance\axis.m

 -- axis ()
 -- axis ([X_LO X_HI])
 -- axis ([X_LO X_HI Y_LO Y_HI])
 -- axis ([X_LO X_HI Y_LO Y_HI Z_LO Z_HI])
 -- axis ([X_LO X_HI Y_LO Y_HI Z_LO Z_HI C_LO C_HI])
 -- axis (OPTION)
 -- axis (OPTION1, OPTION2, ...)
 -- axis (HAX, ...)
 -- LIMITS = axis ()
     Set axis limits and appearance.

     The argument LIMITS should be a 2-, 4-, 6-, or 8-element vector.
     The first and second elements specify the lower and upper limits
     for the x-axis.  The third and fourth specify the limits for the
     y-axis, the fifth and sixth specify the limits for the z-axis, and
     the seventh and eighth specify the limits for the color axis.  The
     special values '-Inf' and 'Inf' may be used to indicate that the
     limit should be automatically computed based on the data in the
     axes.

     Without any arguments, 'axis' turns autoscaling on.

     With one output argument, 'LIMITS = axis' returns the current axis
     limits.

     The vector argument specifying limits is optional, and additional
     string arguments may be used to specify various axis properties.

     The following options control the aspect ratio of the axes.

     "square"
          Force a square axis aspect ratio.

     "equal"
          Force x-axis unit distance to equal y-axis (and z-axis) unit
          distance.

     "normal"
          Restore default aspect ratio.

     The following options control the way axis limits are interpreted.

     "auto"
     "auto[xyz]"
     "auto [xyz]"
          Set nice auto-computed limits around the data for all axes, or
          only the specified axes.

     "manual"
          Fix the current axes limits.

     "tight"
          Fix axes to the limits of the data.

     "image"
          Equivalent to "tight" and "equal".

     "vis3d"
          Set aspect ratio modes to "manual" for rotation without
          stretching.

     The following options affect the appearance of tick marks.

     "tic"
     "tic[xyz]"
     "tic [xyz]"
          Turn tick marks on for all axes, or turn them on for the
          specified axes and off for the remainder.

     "label"
     "label[xyz]"
     "label [xyz]"
          Turn tick labels on for all axes, or turn them on for the
          specified axes and off for the remainder.

     "nolabel"
          Turn tick labels off for all axes.

     Note: If there are no tick marks for an axes then there can be no
     labels.

     The following options affect the direction of increasing values on
     the axes.

     "xy"
          Default y-axis, larger values are near the top.

     "ij"
          Reverse y-axis, smaller values are near the top.

     The following options affects the visibility of the axes.

     "on"
          Make the axes visible.

     "off"
          Hide the axes.

     If the first argument HAX is an axes handle, then operate on this
     axes rather than the current axes returned by 'gca'.

     Example 1: set X/Y limits and force a square aspect ratio

          axis ([1, 2, 3, 4], "square");

     Example 2: enable tick marks on all axes, enable tick mark labels
     only on the y-axis

          axis ("tic", "labely");

     See also: xlim, ylim, zlim, caxis, daspect, pbaspect, box, grid.

Additional help for built-in functions and operators is
available in the online version of the manual.  Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at https://www.octave.org and via the help@octave.org
mailing list.
>> clf;
>> A = magic(5)
A =

   17   24    1    8   15
   23    5    7   14   16
    4    6   13   20   22
   10   12   19   21    3
   11   18   25    2    9

>> imgagesc(A)
error: 'imgagesc' undefined near line 1, column 1
>> imagesc(A)
>> imagesc(A),colorbar,colormap gray
>>
>> imagesc(magic(15)),colorbar,colormap gray
>> a=1;b=2;c=3;
>> a=1,b=2,c=3
a = 1
b = 2
c = 3
>> clear
>> v =zeros(10,1)
v =

   0
   0
   0
   0
   0
   0
   0
   0
   0
   0

>> for i = 1:10,
v(i) = 2^i;
end;
>> v
v =

      2
      4
      8
     16
     32
     64
    128
    256
    512
   1024

>> indices = 1:10;
>> indices
indices =

    1    2    3    4    5    6    7    8    9   10

>> v
v =

      2
      4
      8
     16
     32
     64
    128
    256
    512
   1024

>> i=1;
>> while i<=5,
v(i) = 100;
i=i+1;
end;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

熊猫鹏-梓潼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值