Conditional matrix arrangement in output
1 回表示 (過去 30 日間)
古いコメントを表示
Hello every one my problem is in output.
z=[6
21
36]
but ı want to z as
z=[4
21
12]
how can ı fix this problem.Thanks for your answer and the file Untitled2.m uploaded.
0 件のコメント
採用された回答
KSSV
2021 年 5 月 5 日
x=[1 2 3 4 5
6 7 8 9 10
11 12 13 14 15];
a=1;
b=2;
c=3;
z = zeros(3,1) ;
idx = x(:,1)<3 ;
z(idx) = x(idx,2)*b ;
idx = x(:,1) >= 3 & x(:,1) < 7 ; % 3<= x(:,1)<7
z(idx) = x(idx,2)*c ;
idx = x(:,1) > 7 ;
z(idx) = x(idx,2)*a ;
0 件のコメント
その他の回答 (0 件)
参考
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!