matlab题目求解 matlab编程实例100篇
MATLAB
的题目,求解
首先矩阵A写错了!14之间有个空格
A(1:2,2:3)=(4 2;1 2);
A(2:3,2:3)=(1 2;1 5);
以上两个矩阵点乘等于(4 4;1 10);
det是求矩阵(4 4;1 10)的特征值,依据矩阵知识很容易得到!
matlab试题求解
1.
%方法一
a=1;b=10;n=100;
result = linspace(a,b,n);
%方法二
a=1;b=10;
result = a:(b-a)/100:b;
2.
strA = 'A1bcDEfijK4';
%(1)取第1-5个字符组成字符串
strB = strA(1:5);
%(2) 将字符串倒过来重新排列
strC = strA(size(strA,2):-1:1);
%(3) 将字符串中的大写字母变成相应的小写字母,其余字符不变
pos = find(strA>='A'& strA<='Z');
strD = strA;
strD(pos) = strD(pos) + 32;
%(4) 统计字符串中大写字母的个数。
num = sum(strA >='A' & strA <='Z');
3.
rand('state',0);A=rand(3,5)
%全下标
[i,j] = find(A>.5);
%半下标
k = find(A>.5);
4.
s=sign(randint(1,1000,[],123)-.5);
n=sum(s==-1)
5.
clear, format long, rand('state',1), A=rand(3,3);
%对角元素
B = diag(diag(A));
%其他元素
C = A - B;
6.
function f = myfun(x)
f = 3*x^5+5*x^4+x^2+12;
%求根
x = fzero(@(x) myfun(x),0.1);
%计算f(-1)
result = myfun(-1);
%计算f(x)+g(x)
f1 = sym('3*x^5+5*x^4+x^2+12');
g1 = sym('3*x^2+5*x-3');
fg1 = f1+g1;
fg2 = f1-g1;
fg3 = f1*g1;
fg4 = f1/g1;
MATLAB一题求解
符号表达式问题,做个例子
clc; clear all; close all;
syms x a
eq = (x*(exp(sin(x))+1) - 2*(tan(x)-1))/(x+a);
limit(eq, x, a)
syms x t
eq = (1+2*t/x)^(3*x);
limit(eq, x, inf)
syms x
eq = sqrt(1+exp(x));
diff(eq, x)
syms x n m
eq = x*cos(x);
eq^n
eq^m
syms x
eq = exp(-5*x)*sin(x+pi/6);
int(eq, x, 0, 3*pi)
syms x
eq = x^3*exp(-x);
int(eq)
ans =
(a*(exp(sin(a)) + 1) - (2*sin(a))/cos(a) + 2)/(2*a)
ans =
exp(6*t)
ans =
exp(x)/(2*(exp(x) + 1)^(1/2))
ans =
(x*cos(x))^n
ans =
(x*cos(x))^m
ans =
((exp(-15*pi) + 1)*(3^(1/2) + 5))/52
ans =
-exp(-x)*(x^3 + 3*x^2 + 6*x + 6)
>>
matlaB的5个题目求解
1.
student.term1.phy='80分'
student.term1.eng='65分'
student.term2.eng='65分'
student.term2.mat='78分'
2.
c1=inv(a)*b
c2=a\b