Extracting Data to a workspace

6 Ansichten (letzte 30 Tage)
Chris_WMS
Chris_WMS am 14 Okt. 2020
Kommentiert: Chris_WMS am 14 Okt. 2020
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

Akzeptierte Antwort

Stephen23
Stephen23 am 14 Okt. 2020
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

Weitere Antworten (0)

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by