输入语句 输入数值 ?x=input('please input a number:') please input a number:22 x = 22 输入字符串 ?x=input('please input a string:','s') please input a string:this is a string x = this is a string 输出语句 自由格式 (disp) ?disp(23+454-29*4) 361 ?disp([11 22 33; 44 55 66; 7
计算次幂 Trial>> 3 ^ 2 % 3 raised to the power of 2 ans = 9 MATLAB 计算正弦值 Trial>> sin(pi /2) % sine of angle 90o ans = 1 MATLAB 除以零 Trial>> 7/0 % Divide by zero ans = Inf MATLAB 数学计算表达式 Trial>> 123 * 23.259 ans = 2.8609e+03 MATLAB MATLA
2019年美赛准备:matlab基本题目运算 clear,clc %% 计算1/3 + 2/5 + ...3/7 +10/21 % i = 1; j = 3; ans = 0; % while i <= 10 % ans = ans + i / j; % i = i + 1; % j = j + 2; % end % disp('上述结果为:') % ans % sum((1:10)./(3:2:21)) %% 1到100内能被3和7整除的数之和 ans = 0; for i = 1:100 i