Extract values from matrix/cell in single step
显示 更早的评论
I'm sure there's a nice way of doing this in a single line, just haven't found the right syntax... If I have a several element matrix, how can I extract values from it in one step - specifically, I'm looking to take the screensize available in X & Y...
Size = get(groot,'ScreenSize')
returns a 1x4 double, and I then can access each element as standard Matlab Matrix Indexing:
X_Size = Size(1,3);
Y_Size = Size(1,4);
I'm wanting to do something like the following, which takes the 3 lines into 1:
[Offset_1 Offset_2 X_Size Y_Size] = get(groot,'ScreenSize');
which would assign each of the 4 elements to the 4 variables in the matrix on the left. What's the best practice to do this?
采纳的回答
更多回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!