Save variable in vector form after a loop
Show older comments
here is y code for calculating norm between two vectors and then saving the minimum number and its index in variable r and c, i want to save these two generated after completing the loop, what i am facing a problem is that when i use the the save command it save only the last iteration but i need the whole thing. please help me in my work.
clc; clear all;
filename1 = 'my_file.mat'; %500x1
r2 = load(filename1);
r1 = xlsread('my_excel file','sheet1'); %1060 rows
for i = 1:size(r1,1)
for j = 1:500
T = norm(r2.C(j,:)-r1(i,5:end));
RS(ss) = T;
ss = ss + 1;
end
[r,c]=min(RS);
ABC=fprintf('%5.5f\t %d\n',r,c);
end
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!