I have tried everything and I have no luck.

3 次查看(过去 30 天)
fsadf
  1 个评论
James Tursa
James Tursa 2016-10-4
Please show what you have done so far, and ask specific questions about where you are having problems.

请先登录,再进行评论。

回答(1 个)

Sima
Sima 2016-10-4
What have you tried?
You don't need a loop in Matlab, length(find(X>10)) will give you the number of elements in X that are greater than 10.
disp will display whatever string you give it and mat2str will convert any matrix to a string.
  2 个评论
Connor Maddox
Connor Maddox 2016-10-4
I know I do not need a loop to complete the answer but that is what the assignment says to do.
Sima
Sima 2016-10-4
it's not as efficient but you can do:
larger_than_ten=0;
for i=1:length(X)
if (X(i)>10)
larger_than_ten=larger_than_ten+1;
end
end

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by