How can I use the value of one index in a structured element as the index in a logical statement?

2 views (last 30 days)
I have a set of data within a structured element, with each "label" if you will in the first column, and the data that goes with that in the same row. I'm trying to use the data values within each field as an index to another array in a for loop.
I have several large sets of data of which almost all are indicated by "PointID", and then several "PointID" make up a segment, "SegID". I want to gather data about each individual segment, so I must gather data using the corresponding Point ID.
The following is the code I'm working with--I'm sure it could be more efficient, but not what I need help on :) I'm having trouble in the last for loop, specifically the if statement. I'm getting the error: Matrix dimensions must agree. Error in ExcelConvert (line 37) if PointID{n,2}==ThickPoint; I think it's because I'm working with the structure--the total number of points are the same, but in the structure they are grouped into fields. Attachted is a screen shot of workspace.
Thanks in advance for any direction!
%% Excel to Array for Points Sheet,1);,2);,3);,4);,5);
%% Excel to Array for Segments Sheet,1);,2);,3);,4);,5);,6);,7);
PointID = cell(i,1);
for i=2:43977;
%% Correspond Segment Point Columns (PointID) with Thickness Rows (Take PointIDS within Structure for each segment, use that # as an indice on getting data from the thickness and append to a new table)
for n=1:43977
if PointID{n,2}==ThickPoint;

Answers (1)

Kavya Vuriti
Kavya Vuriti on 15 Nov 2019
Edited: Kavya Vuriti on 15 Nov 2019
I would like to assume dimensions of data field in structure ‘a’ as 43977 x 20 for easy understanding. According to the code provided and assumption made, PointID{n, 2} will be of dimensions 11 x 1 and ThickPoint is of dimensions 358440 x 2. There is mismatch of dimensions during array comparison using ‘==’ which leads to the error message mentioned. Try to make sure that the arrays being compared are of same dimensions.
Hope this helps.

Community Treasure Hunt

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

Start Hunting!

Translated by