Effacer les filtres
Effacer les filtres

Extracting Data to a workspace

2 vues (au cours des 30 derniers jours)
Chris_WMS
Chris_WMS le 14 Oct 2020
Commenté : Chris_WMS le 14 Oct 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

Réponse acceptée

Stephen23
Stephen23 le 14 Oct 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
  1 commentaire
Chris_WMS
Chris_WMS le 14 Oct 2020
Thanks Stephen :)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by