Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

How to fix this error in "for" loop?

1 visualización (últimos 30 días)
Ismail Qeshta
Ismail Qeshta el 19 de Feb. de 2019
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
Hi,
I need to find the Y value that corresponds to the maximum X value for the curves attached herewith.
I tried to use interp1, but I am not sure how to make it for several files.
I tried to develop this code, but it does not work.
I get the following error message:
Index in position 1 is invalid. Array indices must be positive integers or logical values.
Error in ResidualDisp (line 10)
maxy = matDrift(max(matDrift(:,1)),2);
The code:
clear; clc;
Folder = cd;
N=10;
for k = 1:N;
Driftt = sprintf('X%d.out', k);
matDrift = importdata(fullfile(Folder, Driftt));
maxy = matDrift(max(matDrift(:,1)),2);
end
  1 comentario
Yasasvi Harish Kumar
Yasasvi Harish Kumar el 19 de Feb. de 2019
Hi,
I think this expression, max(matDrift(:,1)),2 is not a non-zero integer. I would suggest you have a look into it since you are using it as an index.
Regards

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by