郭彦甫Day2

 

 

 dinv可以返回不可求逆的,inv只能求可逆阵的逆。

 

 

 

%%
%将字符串里的a都替换成z
str='ancsndkao';
'a'==str %找出a所在的位置
str(str=='a')='z';
str

%%
clear;clc
%将字母调换
s1='I like the letter E'
s2=s1;
%s2='E rettel eht ekil I'
a=('I'==s2)
b=('E'==s2)
s2(a)='E';
s2(b)='I';
s2

%%
%Returns a new array with assigned rows and columns
A = {'James Bond', [1 2;3 4;5 6]; pi, magic(5)}
C = reshape(A,1,4) %将A转化为一行四列
%Create a matrix B from the matrix A below using reshape
A = [1:3; 4:6];
B=reshape(A,3,2)

%%
%保存变量为矩阵变量文件
clear; a = magic(4); 
save mydata1.mat
save mydata2.mat -ascii
load('mydata2.mat','-ascii')

%%
%读取和输出excel文件
clear;clc
a=magic(5);
xlswrite('02score.xlsx',a)
Score = xlsread('02score.xlsx')
%Score = xlsread('02score.xlsx', 'B2:D4')
M = mean('Score')';
xlswrite('02Score.xlsx', M, 1, 'F1:F5');
S=std('Score')';
xlswrite('02Score.xlsx', S, 1, 'F6');

%%
clear;clc
x = 0:pi/10:pi; y = sin(x); fid = fopen('sinx.txt','w');
for i=1:11
fprintf(fid,'%5.3f %8.4f\n', x(i), y(i));
end
fclose(fid); type sinx.txt

%%
%1、array concatenation
A=[1,2;3,4];
B=[5,6;7,8];
C=cat(1,A,B) %竖向叠加
D=cat(2,A,B) %横向叠加
E=cat(3,A,B) %前后平行叠加

%%
%2、多维行列
clear;clc
A{1,1}=[1,2;3,4];
A{1,2}='string';
A{2,1}=2-4i;
A{2,2}=7;


A

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值