MATLAB: What is the correct syntax to avoid ‘Error: ()-indexing must appear last in an index expression’

cell arraysmatrixnum2str

Hello, trying to make this code more interactive and efficient:
%Ask user Flight Condition
FlightCond=input('Which flight condition?')
for j = 1:numel(manoev)
DataSetU(num2str(FlightCond))=DataBase((numel(FlightCond)),j);
%<-problem here?
end
%Ask user which manoevre
time=(DatasetU(num2str(manoev))(:,1));
q=DatasetU(num2str(manoev))(:,4);
thanks
Note: DataBase is a cell array 3×5 manoev=[1 2 3 4 5]

Best Answer

_DataSetU(num2str(FlightCond))=DataBase((numel(FlightCond)),j);_
To get the value within a cell use the curlies...
DataBase{numel(FlightCond),j}
This looks peculiar, however as numel(FlightCond) will be 1 always one would presume as the requested value given by the user. Don't you really just want that value (which should be tested to be within the range 1:3 before being used)?
DataBase{FlightCond,j} % looks to me like what you want for RHS
_DataSetU(num2str(FlightCond))_ looks funky, too... *num2str* is going to turn the _FlightCond_ numeric variable into a string representation. When use that as an array index Matlab will convert it to values of the ASCII characters for the numeric representation and you'll get an array of something like 32 elements. This should just be
DataSetU(FlightCond) = ...
Again, you need to test inputs to be in range.
And, since you're moving the row and not changing the row, the loop can be rewritten as
DataSetU(FlightCond)=DataBase{FlightCond,:};
and dispense with the loop altogether.
And, for ease for your user (or you :) ), I'd suggest using a listdlg for the selection--that will ensure a valid selection or an escape/abort and eliminate typo's, etc., ...