How to save output?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
x=[0:n-1];
y=[0:n-1];
figure
for i=1:5
for j=1:5
if rem(((y(j))^2)-((x(i))^3)-2*(x(i))-3,5)==0
plot(x(i),y(j),'r o');
hold on;
end
end
end
grid;
hold off;
How can I save output of loop ? For example in this case I have 6 points (1, 1),(1, 4),(2, 0),(3, 1),(3, 4),(4, 0), how can I save it?
0 commentaires
Réponse acceptée
Star Strider
le 25 Mar 2021
Try this:
n = 10;
x=[0:n-1];
y=[0:n-1];
k = 0; % <- ADD
figure
for i=1:5
for j=1:5
if rem(((y(j))^2)-((x(i))^3)-2*(x(i))-3,5)==0
k = k+1; % <- ADD
xy_mtx(k,:) = [x(i) y(j)]; % <- ADD
plot(x(i),y(j),'r o');
hold on;
end
end
end
grid;
hold off
The results are saved in ‘xy_mtx’.
2 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!