manifold study--matlab (0)

没办法,常常国外网站不能访问,转一下。

 

Abstract : Learn the basic features of Matlab, and learn how to load and visualize signals and images.

 

Basic Matlab commands.

  • Create a variable and an array

    % this is a comment
    a = 1; a = 2+1i; % real and complex numbers
    b = [1 2 3 4]; % row vector
    c = [1; 2; 3; 4]; % column vector
    d = 1:2:7; % here one has d=[1 3 5 7]
    A = eye(4); B = ones(4); C = rand(4); % identity, 1 and random matrices
    c = b'; % transpose

  • Modification of vectors and matrices

    A(2,2) = B(1,1) + b(1); % to access an entry in a vector or matrix
    b(1:3) = 0; % to access a set of indices in a matrix
    b(end-2:end) = 1: % to access the last entries
    b = b(end:-1:1); % reverse a vector
    b = sort(b); % sort values
    b = b .* (b>2); % set to zeros (threshold) the values below 2
    b(3) = []; % suppress the 3rd entry of a vector
    B = [b; b]; % create a matrix of size 2x4
    c = B(:,2); % to access 2nd column

  • Advanced instructions

    a = cos(b); a = sqrt(b); % usual function
    help perform_wavelet_transform; % print the help
    a = abs(b); a = real(b); a = imag(b); a = angle(b); % norm, real part and imaginary part of a complex
    disp('Hello'); % display a text
    disp( sprintf('Value of x=%.2f', x) ); % print a values with 2 digits
    A(A==Inf) = 3; % replace Inf values by 3
    A(:); % flatten a matrix into a column vector
    max(A(:)); % max of a matrix
    M = M .* (abs(M)>T); % threshold to 0 values below T.

  • Display

    plot( 1:10, (1:10).^2 ); % display a 1D function
    title('My title'); % title
    xlabel('variable x'); ylabel('variable y'); % axis
    subplot(2, 2, 1); % divide the screen in 2x2 and select 1st quadrant

  • Programmation

    for i=1:4 % repeat the loop for i=1, i=2, i=3 et i=4
       disp(i); % make here something
    end
    i = 4;
    while i>0 % while syntax
       disp(i); % do smth
       i = i-1;
    end

Load and visualize signals and images

  • Load and plot a signal: (function load_signal.m should be in the toolbox of each course)

    f = load_signal('Piece-Regular', n); % signal of size n
    plot(f);

  • Load and display an image (download function load_image.m should be in the toolboxes)

    I = load_image('lena');
    imagesc(I); axis image; colormap gray(256);

 

转载于:https://www.cnblogs.com/njustyxy/archive/2011/05/29/2062151.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值