如何定义指定的向量

时间:2019-04-08 05:30:23

标签: matlab

我要定义向量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)]

但这不起作用。

1 个答案:

答案 0 :(得分:3)

只需将y定义如下(并进行初始化以获得更好的性能):

y = zeros(1, 1000);
for i = 1:1000
    y(i) = sin(1/i);
end

此外,您也可以不使用for

y = sin(1./(1:1000));