matlab loop
首页/题库/374℃/2024-07-07 08:49:33
matlab loop
(a) Define a function handle for the function f(x) = x2.
(b) Define the variable S to equal zero.
(c) Use a three-line for loop to add each of the following to S in the order given:f(10),
f(9),...,f(2),f(1).Don’t display anything.
(d) After the loop use disp to display the final value of S.
优质解答:
f = @(x)x.^2; %(a) function handler defined
S = 0; %(b) assign the initial value 0 to variable S
for i = 10:-11:1 % (c) initiate the loop that i equals 10, 9, ..., 1
S = f(i); % (c) loop body, calling function handler to retrieve value of S corresponds to each i
end % (c) Thrid line of for loop, close loop
disp(S); %(d) display S with function disp() as required.
再问: 打进去了 虽然不对 但是我改了下 解决了 可以再帮我做一个吗
再答: 要做什么?这个我没编译,直接在板子上写的…… 错了点,不好意思啊
我来回答修改/报错/举报内容!
猜你喜欢
- 请问家用热水器的工作原理?(非太阳能)
- 旅游既能开阔视野,又能陶冶情操.你一定去过很多令你难忘的地方,并且你也一定有想去但没去过的地方.写个英语作文 80字左右
- 已知1mol某物质含有不同短周期的三种元素各1mol,其质子总物质的量为20mol,该物质的电子式为
- 简便运算:1.9+19.9+199.9+1999.9+0.4=
- 〖求答案〗2+7-2+7全部有火柴根组成,移动其中任何一根,答案要求为30说明:因为书写问题作如下解释,2是由横折横三根
- 高一英语单项选择6题(要解析)
- Listen to my head 的歌词
- 白衣服和黑颜色的衣服一起洗染黑了怎么办
- 英语词组中可以出现复数或三单吗
- 是摇响我(要想我)的意思不对吗?送给要分别的恋人最适合了,谁会把小铃铛叫做小钟啊,真无语…
- 初中英语句型转换,我真的没分了= =1.He is going to(stay in hong kong for a w
- 初中英语句型转换Ⅲ(求答案)