Warning: Colon operands should not be logical

2 views (last 30 days)
kkjnkjn

Answers (2)

Walter Roberson
Walter Roberson on 11 Apr 2014
at least one of the entries k(novtrls).endingAdjFixNum is of logical data type instead of numeric.
find(cellfun(@islogical, {k.endingAdjFixNum}))
to see which ones

Image Analyst
Image Analyst on 11 Apr 2014
You forgot to put the error message so we know what line it's complaining about. Put this line before it bombs:
whos FixAdjEnd
k(novtrls).fixX
k(novtrls).fixY
k(novtrls).fixS
k(novtrls).fixE
and tell us what it says so that we have a better chance of helping you while doing this "blind" (i.e. with no data, small snippet of code that can't run, and no full error message).
  2 Comments
gradstudent1
gradstudent1 on 11 Apr 2014
This code may not be the best to work with so I'm thinking of starting from scratch. The idea is that I need to extract all data within a subfield (arranged in a column), but instead of extracting every value in the column, I only want to extract the data from the first row up until the row corresponding to a number in a different subfield. ie: for the subfield FixX rather than extracting X=1:length(FixX) I would like to extract X=1:endingAdjFixNum
I'm sure the syntax is far off so any guidance would be appreciated
Image Analyst
Image Analyst on 11 Apr 2014
Edited: Image Analyst on 11 Apr 2014
See if this snippet helps:
structData.array = randi(9, [5,5]) % Define 2D array
structData.array % Report to command window.
structData.firstIndex = 2;
structData.lastIndex = 3
% Extract subarray
subArray = structData.array(:, structData.firstIndex : structData.lastIndex)
It shows how to extract a sub array out of an array where the array is one field of a structure, and the starting and ending columns are other members/fields of the structure.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!