Extracting Data to a workspace

2 次查看(过去 30 天)
Hi, guys, I would like some help.
The coding below is a m-script file that I run to obtain an 'A' solution.
I would like to retrive the data into one workspace.
The table is the format that I expect to retrieve every variable in the for loop. Is there any method to write to obtain the results like the table?
(The first row is to show how it is arrange and it is not displayed in the workspace)
close all; clear all; clc;
cnt = 0;%count
for X=0:5
for Y=0:5
cnt=cnt+1;
A(cnt,:)=X+Y;
end
end

采纳的回答

Stephen23
Stephen23 2020-10-14
The MATLAB approach:
>> [X,Y] = meshgrid(0:3,0:2);
>> A = X+Y;
>> M = [X(:),Y(:),A(:)]
M =
0 0 0
0 1 1
0 2 2
1 0 1
1 1 2
1 2 3
2 0 2
2 1 3
2 2 4
3 0 3
3 1 4
3 2 5

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by