Why I see only the last value of my row vector in the workspace?
4 次查看(过去 30 天)
显示 更早的评论
I have the following row vectors in my program:
When I run my program, I see in the workspace only the last value of these row vectors as :
I don't know whether my program executes using only the last values of these row vectors or all. What modification my program needs so that I can see all these row vectors in my workspace instead of a singla value? My program is:
clear all; close all; clc;
cloud = 'Homo';
T_para = zeros(5, 17, 20);
T_per = zeros(5, 17, 20);
cth=[1010:10:1200]
h = [1000:1000:4000];
a = [0.01:0.01:0.05];
r = [4:1:20];
fov = [0.2 0.5 1 2 5 10]
snr=[30 40 50 65 75];
for h = 1000:1000:4000
for fov = [0.2 0.5 1 2, 5 10]
dir_arhf = ['Tabledata_', cloud, '\', num2str(h), 'm-', num2str(fov), 'mrad'];
mkdir(dir_arhf);
for a = 0.01:0.01:0.05
for r = 4:1:20
load (['MCdatabase_', cloud, '/', num2str(a), '-', num2str(r), 'um/', num2str(h), 'm-', num2str(fov), 'mrad/I0.mat']);
load (['MCdatabase_', cloud, '/', num2str(a), '-', num2str(r), 'um/', num2str(h), 'm-', num2str(fov), 'mrad/Q0.mat']);
I_para = 1/2 * (I0 + Q0);
I_per = 1/2 * (I0 - Q0);
hh = genHeight(h).^2;
beta_para = sum(I_para, 2) .* hh';
beta_per = sum(I_per, 2) .* hh';
T_para(a * 100, r-3, :) = beta_para';
T_per(a * 100, r-3, :) = beta_per';
Norm_para(a * 100, r-3, :)=(T_para(a * 100, r-3, :)./max(T_para(a * 100, r-3, :)));
Norm_per(a * 100, r-3, :)=(T_per(a * 100, r-3, :)./max(T_per(a * 100, r-3, :)));
for snr=[30, 40, 50, 65, 75]
snr_para(a * 100, r-3, :)=awgn(T_para(a * 100, r-3, :),snr);
snr_per(a * 100, r-3, :)=awgn(T_per(a * 100, r-3, :),snr);
costf=sqrt((snr_para(a * 100, r-3, :)-Norm_para(a * 100, r-3, :)).^2+(snr_per(a * 100, r-3, :)-Norm_per(a * 100, r-3, :)).^2);
save([dir_arhf, '\TABLE.mat'], 'T_per', 'T_para');
end
end
end
end
end
1 个评论
Stephen23
2022-4-19
Look at your FOR loops:
h = [1000:1000:4000]; % this is totally unused
..
for h = 1000:1000:4000 % becaue you redefined h here
The same for all of those other variables.
采纳的回答
KSSV
2022-4-19
You are using the vector as the loop index so obviously you will find only the last value. You can check it your self.
for a = 0.01:0.01:0.05
a
end
fprintf('%f\n',a)
You see, only the last value is printed, as it is the last index value. If you want it as a vector, you need to run like shown below.
a = 0.01:0.01:0.05;
for i = 1:length(a)
a(i)
end
% after loop a
a
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Cloud Integrations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!