How can I make different matrices for different values from other matrices?
1 view (last 30 days)
Show older comments
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
xco = cosd(A)*radius;
%This function represents the distance away from the center in the y-coordinate for each hole
yco = sind(A)*radius;
%Now that we have all the values of each hole calculated, let's put them
%in a more user-friendly display
0 Comments
Answers (1)
Ishaan Mehta
on 27 Jun 2022
Hi Marvin
I understand that you want to display the values in arrays xco and yco in a neat, user-friendly manner.
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
Hope it helps
Ishaan Mehta
0 Comments
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!