zoukankan      html  css  js  c++  java
  • matlab 向量操作作业

    写出下列语句的计算结果及作用

    clear    清除所有变量

    clc    清屏

    A = [2 5 7 1 3 4];    创建行向量并赋值

    odds = 1:2:length(A);    冒号操作符,创建从1到length(A),,步数为2的行向量

    disp('odd values of A using predefined indices')    输出字符串

    A(odds)    输出A中odds中元素对应的下标的值

    disp('odd values of A using anonymous indices')    输出字符串

    A( 1:2:end)    从第一位到最末位,步数为2,输出元素

    disp('put evens into odd values in a new array')    输出字符串

    B(odds) = A(2:2:end)    把B中odds对应的元素赋值为A(2:2:end)输出的值(把A中偶数位置的元素放入B中奇数位置)

    disp('set the even values in B to 99') 输出字符串

    B(2:2:end) = 99    将B中下标为偶数的元素赋值为99

    disp('find the small values in A')    输出字符串

    small = A < 4    产生一个数组,A中每个元素若<4,在新数组中相应的位置赋值为1,否则为0

    disp('add 10 to the small values')    输出字符串

    A(small) = A(small) + 10    A中符合small条件的元素自加10

    disp('this can be done in one ugly operation')    输出字符串

    A(A<4) = A(A<4)+ 10    A中<4的元素自加10

  • 相关阅读:
    zuul prefix
    zuul忽略表达式
    zuul 自定义路由映射规则
    ribbon重试机制
    feign容断忽略某些异常
    cloud turbine
    hystrix 给方法加断路器
    go语言常用函数:cap
    windows 安装 go语言
    mysql win源码比较大 不需要的文件删除 记录下来
  • 原文地址:https://www.cnblogs.com/sq800/p/13153064.html
Copyright © 2011-2022 走看看