Problem extracting values from for loop
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Michael
el 26 de Abr. de 2025
Comentada: Stephen23
el 26 de Abr. de 2025
F = getdatasamples(y_out.clean,[1:567]);
A = getdatasamples(y_out.simout,[1:567]);
figure(2)
hold on
[RMSE] = rmse(F,A);
plot(passband_frequencies,RMSE)
this is within a forloop and I want to get individual RMSE values for each iteration to plot them against anouther varible I have but I am not sure how to do it
1 comentario
Stephen23
el 26 de Abr. de 2025
Note that square brackets are a concatenation operator. The colon returns a vector, which you then concatenate with ... absolutely nothing (which what the orange mlint warning is telling you). So instead of this
[1:567]
you just need
1:567
Respuesta aceptada
Image Analyst
el 26 de Abr. de 2025
Editada: Image Analyst
el 26 de Abr. de 2025
Index the RMSE variable:
for loopIndex = 1 : whatever
F = getdatasamples(y_out.clean, [1:567]);
A = getdatasamples(y_out.simout, [1:567]);
figure(2, 'Name', 'RMSE');
hold on
RMSE(loopIndex) = rmse(F, A);
% Plot (add) a single marker.
plot(passband_frequencies, RMSE(loopIndex), 'b.', 'MarkerSize', 30);
end
hold off;
% Plot the whole array
plot(passband_frequencies, RMSE, 'b-', 'LineWidth', 3);
grid on;
xlabel('Passband Frequency');
ylabel('RMSE')
I'm not sure what passband_frequencies is (scalar or vector of some length) so you might have to index that inside the loop as well, like
plot(passband_frequencies(loopIndex), RMSE(loopIndex), 'b.', 'MarkerSize', 30);
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!