How to save output?

1 vue (au cours des 30 derniers jours)
Ammy
Ammy le 25 Mar 2021
Commenté : Star Strider le 25 Mar 2021
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?

Réponse acceptée

Star Strider
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
Ammy
Ammy le 25 Mar 2021
Thank you very much
Its work
Star Strider
Star Strider le 25 Mar 2021
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

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!

Translated by