Index in position 2 is invalid. Array indices must be positive integers or logical values.

8 ビュー (過去 30 日間)
Zhiying Wang
Zhiying Wang 2019 年 9 月 29 日
コメント済み: yakub sharif 2020 年 3 月 14 日
I=zeros(1,1);
f=zeros(1,1);
n=0;
m=0;
for ky=-6:0.1:6
for kx=-6:0.1:6
f(10*ky+61,10*kx+61)=exp(i*10^(-16)*(2.16*(n+m)*kx+1.245*(n-m)*ky))
I(10*ky+61,10*kx+61)=f(10*ky+61,10*kx+61).^2
end
end
contourf(-6:0.1:6,-6:0.1:6,I,'LineStyle','none');
The error says" Error in hw0928 (line 13) f(10*ky+61,10*kx+61)=exp(i*10^(-16)*(2.16*(n+m)*kx+1.245*(n-m)*ky))" What is worng?

回答 (5 件)

Walter Roberson
Walter Roberson 2019 年 9 月 29 日
0.1 is not exactly representable in finite binary floating point, just the same way that 1/7 is not exactly representable in finite decimal points, and when you increment a variable by 0.1 then even at the places that should logically be integers the result might be something that is not exactly an integer. When you multiply one of those numbers by 10, you might not get exactly an integer.
If you have a fractional floating point value that you intend to multiply by an integer to create an index, the best way to handle the situation is Don't Do That! . Instead, loop on integers and divide by the factor inside the loop to create the floating point value:
for ky10 = -60:1:60
ky = ky10 / 10;
for kx10 = -60:1:60
kx = kx10 / 10;
%code here
f(ky10 + 61), kx10 + 61) = ...
end
end

KALYAN ACHARJYA
KALYAN ACHARJYA 2019 年 9 月 29 日
編集済み: KALYAN ACHARJYA 2019 年 9 月 29 日
for ky=-6:0.1:6
for kx=-6:0.1:6
f(10*ky+61,10*kx+61)=exp(i*10^(-16)*(2.16*(n+m)*kx+1.245*(n-m)*ky))
I(10*ky+61,10*kx+61)=f(10*ky+61,10*kx+61).^2
end
end
Please choose the ky and kx, in such a way the
f(10*ky+61,10*kx+61)
%..^............^
I(10*ky+61,10*kx+61)
%..^..........^
"^" Always gives non zero positive result
Example In Matlab
f(1,1) allowed
f(-1,2) not allowed
I(0.4,-5) not allowed
I(3,6) allowed
Hence, initally for certain iteration your code is runs, but when f(num,num) or I(num,num) num becomes some negative, or decimal number or zero, it reflects error as Index in position 2 is invalid.
There are multiple answer for the same issue, please read the those answer, if you need more clarification. Still If you have any specific problem on this issue, let me know here.
Good Luck!
  2 件のコメント
Zhiying Wang
Zhiying Wang 2019 年 9 月 29 日
I think for ky=-6:0.1:6, kx=-6:0.1:6
f(10*ky+61,10*kx+61) is always non zero positive result. Why it will go wrong?
Walter Roberson
Walter Roberson 2020 年 3 月 11 日
It is nonzero and positive but not exactly an integer because 0.1 is not exactly representable in binary floating point.

サインインしてコメントする。


the cyclist
the cyclist 2019 年 9 月 29 日
Here, I have re-written lots of your code:
n=0;
m=0;
ky_range = -6:0.1:6;
kx_range = -6:0.1:6;
nky = numel(ky_range);
nkx = numel(kx_range);
f = zeros(nky,nkx);
I = zeros(nky,nkx);
for yi = 1:nkx
ky = ky_range(yi);
for xi= 1:nky
kx = kx_range(xi);
f(yi,xi) = exp(i*10^(-16)*(2.16*(n+m)*kx+1.245*(n-m)*ky));
I(yi,xi) = f(yi,xi).^2;
end
end
[yy,xx] = ndgrid(ky_range,kx_range);
figure
contourf(yy,xx,I,'LineStyle','none');
The main issue with your code is that because of floating-point accuracy, your looping variable drifts away from being an exact integer, and therefore cannot be an index into an array.
Instead, I defined the ranges of your x and y in the same way you did, except now I count how many values there are, and loop over that count.
I also corrected your usage of contourf, which requires 2-D inputs for the x and y inputs. See the documentation for that function. Also, see the documentation for ndgrid, which I used to make the required grid.
Sadly, your function still gives an error. That is because m and n are constantly zero, and therefore I is constantly zero, so you cannot make a contour. I don't know how to fix that for you.
  16 件のコメント
Walter Roberson
Walter Roberson 2020 年 3 月 11 日
Earlier you asked,
I mean can the relay,wban and hub positions can be traversed altogether at the same time
You would be most likely to ask that kind of question if you had arrays, relay, wban, hub that were the same sized as each other, and which gave corresponding data -- that the information for relay(J,K) corresponded to wban(J,K) for example, and you wanted to know how to index the three arrays together. Is that not what you are doing?
yakub sharif
yakub sharif 2020 年 3 月 14 日
yes the size for each of them are same. The thing is first I traversed only the relay_x and relay_y. Now If i want to traverse each of them(wban_x,wban_y,relay_x,relay_y,hub_x,hub_y) Is the above part of code a good way to do that? because it's running but taking too long since it would try with all coordinates for wban,hub,relay like If i print it would start from (1,1),(1,1),(1,1), then, (1,1),(1,1),(1,2).....(16,15),(16,15),(16,15) almost 2hrs. So I was just curious Is it the way to index them like xidx,yidx,iidx,jidx,midx,nidx and then to plot should I use surface_grid(yidx, xidx, phiidx)? (Even If I change it to jidx,iidx,phi) it's still same because those are x,y coordinates.

サインインしてコメントする。


Walter Roberson
Walter Roberson 2020 年 2 月 14 日
Warning: this produces one figure for each phi value !! Your code structure does not accumulate or average values over the different phi, so it follows that you need a different heatmap output for each phi value.
hub_x = 8;
hub_y = 8;
wban_x = 5;
wban_y = 4;
wban_P_t = 15; %in dbm
wban_G_t = 1.7;
Relay_P_t = 15; %used 5 earlier
Relay_G_t = 1.7;
N=100;
a = 10;
b = 8;
Rect = [
0 0;
a 0;
a b;
0 b;
0 0];
wban_dist_relay_vec = zeros(size(Rect,1),1);
wban_pow_den_vec = zeros(size(Rect,1),1);
Relay_dist_hub_vec = zeros(size(Rect,1),1);
Relay_pow_den_vec = zeros(size(Rect,1),1);
total_dist_vec = zeros(N, 1);
total_pow_den_vec = zeros(N, 1);
xvals = 1:.5:a;
numx = length(xvals);
yvals = 1:.5:b;
numy = length(yvals);
phivals = -60:1:60;
numphi = length(phivals);
surface_grid = zeros(numy, numx, numphi);
for xidx = 1:numx
cur_x = xvals(xidx);
for yidx = 1:numy
cur_y = yvals(yidx);
wban_dist_hub = sqrt((hub_x - wban_x).^2 + (hub_y - wban_y).^2);
cur_dist_hub = sqrt(double((hub_x - cur_x).^2 + (hub_y - cur_y).^2));
for phiidx = 1:numphi
phi = phivals(phiidx);
phi3db = 93; % The angle causing 3-dB attenuation = 65 degs
Am = 30; % Maximum attenuation = 30 dB
% Horizontal radiation pattern
Aeh = -min( ( 12* ((phi/phi3db).^2)), Am ) ;
% Vertical radiation pattern
Aev = 0; % We are assuming "zero" attenuation on the vertical domain.
% Combined attenuation
A = -min ( (- (Aev+Aeh ) ), Am );
% Transmitter antenna gain
wban_GT1 = wban_G_t + A;
wban_dist_relay_vec = cur_dist_wban;
Pow_Den_wban = (db2pow(wban_GT1) * db2pow(wban_P_t)) / (4 * pi * wban_dist_hub^2.4);
wban_pow_den_vec = Pow_Den_wban;
% Relay to hub
Relay_dist_hub_vec = cur_dist_hub;
Pow_Den_Relay = (db2pow(Relay_G_t) * db2pow(Relay_P_t)) / (4 * pi * cur_dist_hub^2.4);
Relay_pow_den_vec = Pow_Den_Relay;
total_dist_vec = wban_dist_hub + cur_dist_hub;
total_pow_den_vec = Pow_Den_Relay + Pow_Den_wban;
surface_grid(yidx, xidx, phiidx) = total_pow_den_vec;
fprintf("(%f, %f, %f), Pow_Den_wban:%f, Pow_Den_Relay:%f, total_pow_den_vec:%f\n", cur_x, cur_y, phi, Pow_Den_wban, Pow_Den_Relay, total_pow_den_vec);
end
end
end
for phiidx = 1 : numphi
phi = phivals(phiidx);
figure();
heatmapHandle = heatmap(surface_grid(:,:,phiidx), 'ColorMap', jet(100))
heatmapHandle.YDisplayData = 1:.5:8
heatmapHandle.XDisplayData = 1:.5:10
heatmapHandle.YDisplayData = flipud(heatmapHandle.YDisplayData);
heatmapHandle.GridVisible = 'on';
caxis(heatmapHandle,[0 10]);
title( sprintf('phi = %f', phi))
end
  11 件のコメント
Walter Roberson
Walter Roberson 2020 年 3 月 2 日
Unrecognized function or variable 'wban_P_t_temp'.
Error in relay_reduction (line 127)
Pr_wban = (wban_P_t_temp + wban_GT1 - PL_LoS_wban); %in dB all; power received from wban to relay
yakub sharif
yakub sharif 2020 年 3 月 3 日
Sorry my bad, the wban_P_t_temp should be replaced by wban_P_t only. this is the code below, what I wanted is for every relay_P_t temp there would be on heatmap showing the total_pow_den_vec(row) and SAR.
% clear all;
% close all;
clc;
a = 16; % a = length
b = 15; % b = width
N = 240; % N = no. of Relays
hub_x = 15;
hub_y = 15;
X = [1 8];
Y = [1 8];
Relay_P_t = 15; %used 15 earlier
Relay_G_t = 8; %used 1.7 earlier
% when using relay stations
wban_P_t = 15; %in dbm
wban_G_t = 1.7; %in dbi
% Relay_P_t_temp = 15; %used 5 earlier
% wban_P_t_temp = 1.7; %in dbm
BW = 4e6;
wban_x = 1;
wban_y = 1;
%SNR calculation
T = 295; % Room temperature = 295 K
NF_UE = 19.2; % Noise figure = 19.2 dB
N_UE = -198.5992 + 10*log10(T) + 10*log10(BW) + NF_UE;
epsn = 39.2; % Permittivity: fccid.io/XRAFB505/RF-Exposure Info
delta = 113e-3; % Skin penetration depth = 113mm @2.4 GHz: ncbi.nlm.nih.gov
rho = 1.80; % Skin conductivity: fccid.io/XRAFB505/RF-Exposure Info
% epsn = 50.97; % for whole body also in https://itis.swiss/virtual-population/tissue-properties/database/tissue-frequency-chart/ Permittivity: fccid.io/XRAFB505/RF-Exposure Info
% delta = 22.6e-3; % Skin penetration depth = 113mm @2.4 GHz: ncbi.nlm.nih.gov
% rho = 1.97; % Skin conductivity: fccid.io/XRAFB505/RF-Exposure Info
phi3db = 93; % The angle causing 3-dB attenuation = 93 degs
Am = 30; % Maximum attenuation = 30 dB
fc = 2.4;
distMax = 1;
distIncr = 5e-3;
dist0 = 1e-4 : distIncr : distMax;
ISD = .2;
one_cell_prpg = dist0(1:find(dist0 < ISD/2, 1, 'last' ));
two_cell_prpg = [one_cell_prpg ISD/2 fliplr(one_cell_prpg(2:end))];
num_two_cell_prpgs = ceil(size(dist0,2) / size(two_cell_prpg,2));
dd = 1 : N;
wban_dist_relay_vec = zeros(N,1);
wban_pow_den_vec = zeros(N,1);
Relay_dist_hub_vec = zeros(N,1);
Relay_pow_den_vec = zeros(N,1);
total_dist_vec = zeros(N, 1);
total_pow_den_vec = zeros(N, 1);
rand_coordinate = rand(N,2);
xvals = 1:a;
numx = length(xvals);
yvals = 1:b;
numy = length(yvals);
surface_grid = zeros(numy, numx);
surface_grid2 = zeros(numy, numx);
surface_grid3 = zeros(numy, numx);
row = 0;
for xidx = 1:numx
for yidx = 1:numy
relay_x = xvals(xidx);
relay_y = yvals(yidx);
row= row + 1;
if (relay_x == 0 || relay_y == 0)
continue;
end
phivals = (atan((relay_y-wban_y)./(relay_x-wban_x))-atan((hub_y-wban_y)./(hub_x-wban_x))).*180./pi;
numphi = length(phivals);
wban_dist_hub = sqrt((hub_x - wban_x).^2 + (hub_y - wban_y).^2); % wban to hub distance
relay_dist_hub = sqrt(((hub_x - relay_x).^2 + (hub_y - relay_y).^2)); % hub to realy distance
if (relay_dist_hub == 0)
continue;
end
% wban to Relay
wban_dist_relay_vec(row) = wban_dist_hub;
% Relay to hub
Relay_dist_hub_vec(row) = relay_dist_hub;
% wban to Hub
total_dist_vec(row) = wban_dist_hub + relay_dist_hub;
% Path loss
PL_LoS_wban = 24*log10(wban_dist_hub)+ 24*log10(fc)+38.93;
PL_LoS_relay = 24*log10(relay_dist_hub)+ 24*log10(fc)+38.93;
% % Relay to hub power density vector
% Pow_Den_Relayy = (Relay_G_t + Relay_P_t-30)-10*log10(4*pi*(relay_dist_hub*.1)^2.4);
% Pow_Den_Relay = db2pow(Pow_Den_Relayy);
% Relay_pow_den_vec(row) = Pow_Den_Relay;
Pow_Den_wban_relayless = db2pow((wban_G_t + wban_P_t-30)- 10*log10(4 * pi * (wban_dist_hub*.1)^2.4));
Pr_direct = (wban_P_t + wban_G_t - PL_LoS_wban);
avg_SNR_direct = Pr_direct - N_UE;
% fprintf("avg_SNR_direct: %.3f\n", avg_SNR_direct)
R = BW*log2(1 + db2pow(avg_SNR_direct))/1e9; % power received from wban to relay
Relay_P_t_temp = Relay_P_t;
% Calculating antenna Gain
for phiidx = 1:numphi
phi = phivals(phiidx);
% fprintf("phi: %.3f\n", phi);
% Horizontal radiation pattern
Aeh = -min( ( 12* ((phi/phi3db).^2)), Am ) ;
% Vertical radiation pattern
Aev = 0; % We are assuming "zero" attenuation on the vertical domain.
% Combined attenuation
A = -min ( (- (Aev+Aeh ) ), Am );
while 1
% Transmitter antenna gain
wban_GT1 = wban_G_t + A;
% Final Received Power
Pr_wban = (wban_P_t + wban_GT1 - PL_LoS_wban); %in dB all; power received from wban to relay
% wban to relay power density vector
Pow_Den_wbann = (wban_GT1 + wban_P_t-30)- 10*log10(4 * pi * (wban_dist_hub*.1)^2.4);
Pow_Den_wban = db2pow(Pow_Den_wbann);
wban_pow_den_vec(row) = Pow_Den_wban;
total_pow_den_vec(row) = Pow_Den_Relay + Pow_Den_wban;
% Relay to hub power density vector
Pow_Den_Relayy = (Relay_G_t + Relay_P_t-30)-10*log10(4*pi*(relay_dist_hub*.1)^2.4);
Pow_Den_Relay = db2pow(Pow_Den_Relayy);
Relay_pow_den_vec(row) = Pow_Den_Relay;
% power received from relay to hub
Pr_relay = (Relay_P_t_temp + Relay_G_t - PL_LoS_relay); %in dB all;
% avg_SNR = Pr_wban+Pr_relay -N_UE;
avg_SNR = Pr_relay - N_UE;
% fprintf("avg_SNR: %.3f\n", avg_SNR)
% Average data rate; from wban to relay + relay to hub
R_Relay = BW*log2(1 + db2pow(avg_SNR))/1e9;
if R_Relay <= R
break;
end
Relay_P_t_temp = Relay_P_t_temp - 0.1;
end
fprintf("(%d, %d),Data Rate: %.3f, %.3f, %.3f\n", relay_x, relay_y, R, R_Relay);
fprintf("phi: %d, Relay_P_t_temp: %0.3f", phi, Relay_P_t_temp);
fprintf("\n");
angles_Wban = 210*pi./180;
angle_width = 4*pi/6;
angle_begins = angles_Wban - angle_width/2;
theta1 = angle_begins(1) + rand(1,N) * angle_width;
angle_rotation_new = abs( angles_Wban - theta1 );
for pp = 1 : size(phi,2)
m = abs( cos(phi*pi/180) / sqrt(1 - epsn^(-1)*(sin(phi*pi/180))^2) );
rTE = ( cos(phi*pi/180) - sqrt(epsn - (sin(phi(pp)*pi/180)).^2) ) / ( cos(phi*pi/180) + sqrt(epsn - (sin(phi*pi/180)).^2) );
rTM = ( epsn*cos(phi(pp)*pi/180) - sqrt(epsn - (sin(phi(pp)*pi/180)).^2) ) / ( epsn*cos(phi(pp)*pi/180) + sqrt(epsn - (sin(phi(pp)*pi/180)).^2) );
TTE = 1 - (abs(rTE))^2;
TTM = 1 - (abs(rTM))^2;
% Specific Absorption Rate (SAR)
SAR = (2 *(total_pow_den_vec(row)) * TTE * m ) / (delta * rho);
end % End of for pp
% fprintf("(%d, %d), phi: %d, avg_SNR: %d, R_Relay: %d, Pr_wban: %d, Pr_relay: %d, m: %f, TTE: %f, SAR: %f, Pow_Den_wban: %f, Pow_Den_Relay: %f, total_pow_den_vec(row): %f\n", relay_x, relay_y, phi, avg_SNR, R_Relay, Pr_wban, Pr_relay, m, TTE, SAR, Pow_Den_wban, Pow_Den_Relay, total_pow_den_vec(row));
% fprintf("(%d, %d), phi: %d, Relay_P_t: %d, avg_SNR: %d, R_Relay: %d, SAR: %f, Pow_Den_wban: %f, Pow_Den_Relay: %f, total_pow_den_vec(row): %f\n", relay_x, relay_y, phi, Relay_P_t_temp, avg_SNR, R_Relay, SAR, Pow_Den_wban, Pow_Den_Relay, total_pow_den_vec(row));
surface_grid(yidx, xidx, phiidx) = total_pow_den_vec(row);
surface_grid2(yidx, xidx, phiidx) = SAR;
surface_grid3(yidx, xidx, phiidx) = R_Relay;
if row == 1
break;
end
end
end
end
% end
% end
% fprintf("%d, %d, %d\n", relay_x, relay_y, row);
% figure;
% plot(wban_dist_hub,Pow_Den_Relay);
% figure;
% plot(wban_dist_relay_vec,wban_pow_den_vec);
% sorted = zeros(N,2); sorted(:,1) = wban_dist_relay_vec; sorted(:,2) =
% wban_pow_den_vec; after_sorting = sortrows(sorted, 2);
% unique_after_sorting = unique(after_sorting,'rows');
sorted = zeros(N,2);
sorted(:,1) = Relay_dist_hub_vec;
sorted(:,2) = Relay_pow_den_vec;
after_sorting = sortrows(sorted, 2);
unique_after_sorting = unique(after_sorting,'rows');
% figure;
% plot(wban_dist_relay_vec(row),avg_SNR, 'r', 'LineWidth', 2);
% hold on
%plot for SAR
figure;
%plot(wban_dist_relay_vec(row),SAR_64(dd,pp), 'g','LineWidth',2);
xlabel('distance (m)');
ylabel('SAR');
% figure;
max_range = 90;
plot_x = unique_after_sorting(81:max_range,1);
plot_y = unique_after_sorting(81:max_range,2);
% plot(plot_x, plot_y, '*', 'LineWidth', 2);
plot(plot_x, plot_y);
grid on
xlabel('total Distance ')
ylabel('Power Density (W/m^2)');
% figure;
% %plot(wban_dist_relay_vec(row),avg_SNR, 'r', 'LineWidth', 2);
% hold on
% %plot for SAR
% figure;
% %plot(wban_dist_relay_vec(row),SAR_64(iter,dd,pp), 'g','LineWidth',2);
% xlabel('distance (m)');
% ylabel('SAR');
% figure;
% semilogy(dist0,avgSAR,'LineWidth',2);
% grid on
% xlabel('Distance between human head and wearable device(m)')
% ylabel('SAR (W/kg)');
% set(gca,'FontSize',12)
% figure;
%plot(unique_after_sorting(2:size(unique_after_sorting,1),1),unique_after_sorting(2:size(unique_after_sorting,1),2));
% grid on
% xlabel('Wearable to Relay Distance (m) ')
% ylabel('Wearable to Relay Power Density (W/m^2)');
% figure;
% xvar=linspace(.5,1);
% yvar=linspace(.5,1);
% imagesc(xvar, yvar, surface_grid);
%set (gca, 'ydir', 'reverse')
%fliplr('ydir')
% set(gca, 'Ydir','normal')
% %colormap('hot');
% colorbar;
%figure;
%imagesc(surface_grid2);
colorbar;
%figure;
%imagesc(surface_grid1);
%set ( gca, 'ydir', 'reverse' )
%fliplr('ydir')
%set(gca, 'Ydir','normal')
%colormap('hot');
colorbar;
% figure;
% xvar=linspace(4,10);
% yvar=linspace(4,10);
% figure;
% values_to_plot = max(surface_grid,[],3);
% heatmapHandle = heatmap(values_to_plot, 'ColorMap', jet(100));
% heatmapHandle.XLabel = 'Power Density';
% heatmapHandle.YDisplayData = flipud(heatmapHandle.YDisplayData);
% heatmapHandle.GridVisible = 'on';
% caxis(heatmapHandle,[0 10]);
figure;
values_to_plot = max(surface_grid,[],3);
heatmapHandle = heatmap(values_to_plot, 'ColorMap', jet(100));
heatmapHandle.XLabel = 'Power Density';
heatmapHandle.YDisplayData = flipud(heatmapHandle.YDisplayData);
heatmapHandle.GridVisible = 'on';
caxis(heatmapHandle,[0 10]);
colorbar;
figure;
% xvalues = 1:10
% yvalues = 1:8
% clf
% xvar=linspace(1,.5,5);
% yvar=linspace(1,.5,5);
values_to_plott = max(surface_grid2,[],3);
heatmapHandle = heatmap(values_to_plott, 'ColorMap', jet(100));
heatmapHandle.XLabel = 'SAR';
heatmapHandle.YDisplayData = flipud(heatmapHandle.YDisplayData);
heatmapHandle.GridVisible = 'on';
caxis(heatmapHandle,[0 4]);
figure;
values_to_plottt = max(surface_grid3,[],3);
heatmapHandle = heatmap(values_to_plottt, 'ColorMap', jet(100));
heatmapHandle.XLabel = 'Data Rate';
heatmapHandle.YDisplayData = flipud(heatmapHandle.YDisplayData);
heatmapHandle.GridVisible = 'on';
caxis(heatmapHandle,[0.2 .4]);
% y = [1 1.5 2 2.5 3 3.5 4.5 6.5 7.5 8.5 9.5 10]
% set(gca, 'YTick', 1:length(y), 'YTickLabel', y)
% set(gca, 'Ydir','normal')
% fig = figure;
% response = fig2plotly(fig, 'filename', 'matlab-basic-heatmap');
% plotly_url = response.url;
% figure;
% plot(sort(Relay_dist_hub_vec),sort( Relay_pow_den_vec));
% figure;
% plot(sort(total_dist_vec), sort(total_pow_den_vec));
%
% % set(legend, 'Location', 'Best')
% % drawnow
%
% a1 = 0;
% b1 = a;
% x = (b1-a1).*rand(N,1)+a1;
% a2 = 0;
% b2 = b;
% y = (b2-a2).*rand(N,1)+a2;
% %x = rand(0,a);
% %y = rand(0,b);
% plot(Rect(:,1),Rect(:,2),'r');
% hold on
% plot(x,y,'*b')
% % cdf = duniformcdf(L,W,x);
% % stairs(x,cdf)
%
% total_pow_den_vec(row)1 = makedist('Uniform');
% x = 0:.1:a;
% total_pow_den_vec(row)f1 = total_pow_den_vec(row)f(total_pow_den_vec(row)1,x);
% figure;
% stairs(x,total_pow_den_vec(row)f1,'r','LineWidth',2);
% total_pow_den_vec(row)1 = makedist('Uniform');
% x = 0:.01:a;
% cdf1 = cdf(total_pow_den_vec(row)1,x);
% figure;
% plot(x,cdf1,'r','LineWidth',2);
% hold on;
% figure;
% x = -140:10:140;
% total_pow_den_vec(row)2 = makedist('Uniform','lower',-2,'upper',2);
% total_pow_den_vec(row)f2 = total_pow_den_vec(row)f(total_pow_den_vec(row)2,x);
% stairs(x,total_pow_den_vec(row)f2,'k:','LineWidth',2);
% %% Creation of a cdf
%compute_one_minus_cdf( reshape(rate_final, 1,size(rate_final,1)*size(rate_final,2)*size(rate_final,3)*size(rate_final,4)*size(rate_final,5)*size(rate_final,6)) )
%compute_one_minus_cdf( reshape(total_pow_den_vec, 1,size(total_pow_den_vec,1)*size(total_pow_den_vec,2)*size(total_pow_den_vec,3)*size(total_pow_den_vec,4)) )
%compute_one_minus_cdf( reshape(total_pow_den_vec(row), 1,size(Si_in_pow,1)*size(Si_in_pow,2)*size(Si_in_pow,3)*size(Si_in_pow,4)) )
%compute_one_minus_cdf( reshape(SAR, 1,size(SAR,1)*size(SAR,2)*size(SAR,3)*size(SAR,4)) )
% close all;

サインインしてコメントする。


yakub sharif
yakub sharif 2020 年 3 月 11 日
Hello Just one more question? Could you please let me know in my code where I used to vary the location of Relay positions in the line
for xidx = 1:numx
for yidx = 1:numy
relay_x = xvals(xidx);
relay_y = yvals(yidx);
row= row + 1;
if (relay_x == 0 || relay_y == 0)
continue;
end
can the positions of wban and hub be varied as well? I mean can the relay,wban and hub positions can be traversed altogether at the same time, If possible then how to modify that in the code, could you please help me? thanks

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by