内联写矩阵和数组操作

时间:2017-05-17 20:08:22

标签: arrays matlab matrix inline

我有两个矩阵,我在其中一个的第一行之后排序,然后以相同的方式对另一个进行排序:

arrayXSorted = matrixB(:,1)(arrayYIndex);

我想在一行中写第2行和第3行,但我无法弄清楚如何在内联中执行'矩阵'数组。

我确实想到了这样的事情:

arrayXSorted = (matrixB(:,1))(arrayYIndex);

using System;
using System.Collections.Generic;
using Newtonsoft.Json;

static class MainClass {
    public static void Main() {
        var node = new Node(null);
        node.AddChild();

        var settings = new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects, Formatting = Formatting.Indented };

        //serializing
        string json1 = JsonConvert.SerializeObject(node, settings);
        Console.WriteLine("Before deserializing:");
        Console.WriteLine(json1);
        Console.WriteLine();

        //deserializing
        node = JsonConvert.DeserializeObject<Node>(json1, settings);

        //serializing again
        string json2 = JsonConvert.SerializeObject(node, settings);
        Console.WriteLine("After deserializing:");
        Console.WriteLine(json2);
        Console.WriteLine();

        Console.ReadLine();
    }
}

[JsonObject(IsReference = true)]
class Node {
    public Node Parent = null;
    public List<Node> Children = new List<Node>();

    public Node(Node parent) {
        this.Parent = parent;
    }

    public void AddChild() {
        this.Children.Add(new Node(parent: this));
    }
}

但两者都无效。

如何内联?

1 个答案:

答案 0 :(得分:1)

如下所示,您可以在第1列中获取指定的行。

arrayXSorted = matrixB(arrayYIndex,1)