MATLAB: Extract out values out of loop loop Can any one pls help how to extarct [XYZ,H,D,I,F] out of the below loop Thanks for i= 1: length(Hi) [XYZ,H,D,I,F] = wrldmagm(Hi(i),Lat(i),Long(i),decimalYear(i)); end Can Best Answer Make them arrays and assign to the elements. E.g.,for i= 1: length(Hi) [XYZ(:,i),H(i),D(i),I(i),F(i)] = wrldmagm(Hi(i),Lat(i),Long(i),decimalYear(i));endConsider pre-allocating XYZ, H, D, I, and F also. Related SolutionsMATLAB: Optimise for loop in using cell array lengthboundaries = cellfun(@length,boundaries); MATLAB: Vector input to wrldmagm The function only accepts scalar values not vectors. You may use a loop to extract the magnetic field for every element of your data. Related QuestionAm I getting “Array indices must be positive integers or logical values” errorHow i can find the DTFT of sequence without using fft inbuilt functionFor loop and store output values
Best Answer