How to use find function to create a sceond array?
显示 更早的评论
I'm trying to use find function to create a new array(Y) where the values are natural logarithms of an array (X) if these values are greater than 1. If there are any values remaining in (Y), I need to add 8 to each of the corresponding elements in A.
So far I got this but I'm pretty sure I've got something missing as I dont think I get the right result:
bold
X=[1.92 0.05 -2.43 -0.02 0.85];
Y=zeros(size(X));
log=find(log(X)>=1);
Y(1:length(log))=X(log);*
Any advice would be helpful, thank you.
7 个评论
Azzi Abdelmalek
2012-11-6
编辑:Azzi Abdelmalek
2012-11-6
What is the size of A
X is not used
Patrick
2012-11-6
Azzi Abdelmalek
2012-11-6
what should be the result in this case?
Patrick
2012-11-6
Azzi Abdelmalek
2012-11-6
do you mean to add 8 or log(8)
Azzi Abdelmalek
2012-11-6
编辑:Azzi Abdelmalek
2012-11-6
it's not clear, how did you get 0.2833
Patrick
2012-11-6
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!