1、MATLAB实验报告科学计算与数据处理实验报告学号Xxxxxx姓名xxxxxxx实验名称基于MATLAB的科学计算实验实验目的1.掌握MATLAB中数组的创建和操作方法2.掌握MATLAB中常用的数值计算方法3.掌握MATLAB中常用的符号计算方法实验方案1.一维数组创建实验(1) 直接输入法:1 2 3 4(2) 步长生成法:0:2:10(3) 定数线性采样法: linspace(0,5,20)(4) 定数对数采样法: logspace(1,2,5)2.高维数组创建实验(1) 直接输入法: 1 2 3;9 8 7(2) 使用下标: A(3,3,3)=3(3) 使用低维数组: clear;C(
2、:,:,3)= 1 1 1;2 2 2;C(:,:,2)= 1 1 1;2 2 2*2;C(:,:,1)= 1 1 1;2 2 2*3(4) 使用创建函数: (cat、repmat、reshape)cat(3,1 1 1;1 1 1,1 1 1;1 1 1*2,1 1 1;1 1 1*3)repmat(1 2 3;9 8 7,2,2,3)reshape(1:64,4,4,4)3. 标准数组创建实验zeros(3,4) ones(3,4)eye(9,9)magic(4)randn(4)4. 矩阵变换实验diag(Data)fliplr(Data)flipud(Data)rot90(Data)tr
3、il(Data)triu(Data)diag(Data,1)/diag(Data,-2)/* 以向量v的元素作为矩阵X的第k条对角线元素,当k=0时,v为X的主对角线;当k0时,v为上方第k条对角线;当k0.5C=A0时,v为上方第k条对角线;当k0.5C=A0.7B&CB|CBCxor(B,C)A = 0.341193569414883 0.309290159790958 0.370413556632117 0.5340790176266 0.838496044938081 0.702739913240377 0.727113216929677 0.568072461007776 0.546
4、571151829106B = 0 0 0 1 1 1 1 1 1C = 1 1 1 1 0 0 0 1 1ans = 0 0 0 1 0 0 0 1 1ans = 1 1 1 1 1 1 1 1 1ans = 1 1 1 0 0 0 0 0 0ans = 0 0 0 0 1 1 1 0 0ans = 1 1 1 0 1 1 1 0 08. 矩阵分析实验:(1)norm(magic(3)(2)cond(magic(3)(3)det(magic(3)(4) rank(magic(3)(5)eig(magic(3)(6)null(magic(3)(7) chol(eye(3)(8) L,U=lu(
5、rand(3)(9)Q,R=qr(rand(3)(10)S,V,D=svd(rand(3)ans = 15ans = 4.33012701892219ans = -360ans = 3ans = 15 4.89897948556636 -4.89897948556636ans = Empty matrix: 3-by-0ans = 1 0 0 0 1 0 0 0 1L = 1 0 0 0.429982284033605 1 0 0.709395345817263 0.55892485105048 1U = 0.661442576382325 0.0647811229632725 0.42349
6、6256851051 0 0.960480203063621 0.333415864340266 0 0 -0.152*3659Q = -0.571080368247274 -0.4543176193232 -0.683712449627077 -0.298067839727582 -0.661280709471457 0.688377357414565 -0.764867815980442 0.59691148762059 0.242226959737934R = -0.758048464238721 -1.08207086599865 -0.831749947234468 0 -0.313
7、471402214919 0.121427394174719 0 0 0.308258328761994S = -0.716740765533402 0.481441384916589 -0.504476825941678 -0.3263963313222 -0.870905921565484 -0.367407553925589 -0.616237056595919 -0.0986765862389493 0.781354478713872V = 1.42406638330796 0 0 0 0.475014300667544 0 0 0 0.103909300080398D = -0.69
8、407351285109 -0.273285569448231 -0.666015732764552 -0.674175314974177 0.57121299527373 0.46819158333943 -0.252486838148083 -0.773970743350011 0.580706195076499. 数值计算实验(1) syms x;f=log(x);diff(f);ans = 1/x(2) x,y=meshgrid(-5:0.5:5)z=1./(x.2-2*x+4)+1./(y.3-2*y+4)g=gradient(z)subplot(1,2,1),surf(x,y,z)
9、subplot(1,2,2),surf(x,y,z,g)x = Columns 1 through 6 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.5 -3 -2.5 -5 -4.5 -4 -3.
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1