# How can I make different matrices for different values from other matrices?

2 ビュー (過去 30 日間)
Marvin Brown 2021 年 11 月 30 日

So I have 2 arrays, one containing a bunch of x-coordinates and the other containing a bunch of y-coordinates. They're all in order, such as xco(1,1) is the x-coordinate that pairs with yco(1,1) {Which is the array of y-coordinates}. I would like to pair xco(1,1) and yco(1,1) into a single matrix listing the propper x and y coordinates in a neat display. The issue is the number of x and y coordinates are variable based on user inputs and expressions coded earlier in the program. So for each time a user uses the program the number of x and y coordinates will vary. But I want all the coordinates to show up in one matrix without having to explicitly code them in, which wouldn't work anyways because the number of coordinates vary with each run of the program.
Here is some of the code I've written so far:
for a = 1:holes;
angles = ameasure*a;
A(a)=angles;
end
%Now to find the distance in the x-corrdinate away from the center for each hole
%This function represents the distance away from the center in the y-coordinate for each hole
%Now that we have all the values of each hole calculated, let's put them
%in a more user-friendly display

サインインしてコメントする。

### 回答 (1 件)

Ishaan Mehta 2022 年 6 月 27 日
Hi Marvin
I understand that you want to display the values in arrays xco and yco in a neat, user-friendly manner.
This can by done using table datatype in MATLAB.
Here is a code snippet for the same.
% dummy data for xco and yco
xco = randi([1 100], [1 10]);
yco = randi([1 100], [1 10]);
myTable = table(xco', yco'); % create a table with the values of xco and yco
myTable.Properties.VariableNames = ["xco" "yco"]; % rename the columns
myTable
myTable = 10×2 table
xco yco ___ ___ 66 67 45 9 48 46 65 3 21 60 29 80 52 74 56 91 39 63 78 81
Hope it helps
Ishaan Mehta

サインインしてコメントする。

R2021a

### Community Treasure Hunt

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

Start Hunting!