我要定义向量using System;
class TestClass
{
static void Main()
{
Action origin = new Action(() => { Console.WriteLine("1st line"); });
Action copyFromOrigin;
copyFromOrigin = origin;
origin += new Action(() => { Console.WriteLine("2nd line"); });
copyFromOrigin.Invoke();
//result is "1st line", why the "2nd line" is missing?
//shouldn't the copyFromOrigin is referencing the origin?
Console.ReadKey();
}
}
。
但是我不知道该怎么做。我定义了
y=[sin(1),sin(1/2),...,sin(1/1000)]
但这不起作用。
答案 0 :(得分:3)
只需将y
定义如下(并进行初始化以获得更好的性能):
y = zeros(1, 1000);
for i = 1:1000
y(i) = sin(1/i);
end
此外,您也可以不使用for
:
y = sin(1./(1:1000));