本帖最后由 jiuri1989 于 2012-3-13 11:00 编辑
同一组数据不同格式输出,用switch case 反倒复杂了。怎么才能简单点儿??
- format compact
- clc
- A = rands(3,3);
- B = inv(A);
- C = B * A;
- D = B .* A;
- E = sqrt(C);
- E_abs = abs(E);
- for a = 1:6
- switch a
- case 1
- format short
- case 2
- format long
- case 3
- format short e
- case 4
- format long e
- case 5
- format short g
- case 6
- format long g
- end
- str = sprintf('%s %d %s', 'Now shi di ',a,' zhong ge shi');
- disp ('============================================================')
- disp (str)
- A,B,C,D,E,E_abs,
- end
复制代码
一周热门 更多>