What is the mistake in this code ?

Error using importdata (line 139) Unable to open file.
Error in Capacity_Total_up_Output (line 19) C_Total{i} = importdata(fullfile(P,F_Total));
%The Two Files are C_Total_1.txt , C_Total_2.txt
clc;
clear;
N = (6:10).^2; %Number of Elements IRS
K = 2:2:10; %Number of Single Antennas UE
C_Total_1 = importdata('C_Total_1.txt') ; % Total Capacity
C_Total_2 = importdata('C_Total_2.txt') ; % Total Capacity
P = 'C:\Users\tripo\Documents\Total_April_Capacity\ART';
Total_File = [1,2];
Total_Capacity_File = numel(Total_File);
C_Total = cell(1,Total_Capacity_File);
for i = 1:Total_Capacity_File
F_Total = sprintf('C_Total_%d.txt',Total_File(i));
% C_Total{i} = importdata(fullfile(P,F_Total));
C_Total{i} = importdata(F_Total);
end
% C_Total_up = mean(cat(3, C_Total{:}), 3);
% C_Total_up = reshape([C_Total{1};C_Total{2}],size(C_Total{1},1),[]);
C_Total_up = C_Total{1}+C_Total{2};
%%
figure(1)
newcolors = [0 0.4470 0.7410
0.8500 0.3250 0.0980
0.9290 0.6940 0.1250
0.25 0.80 0.54
1 0.4470 0.7410
0.7 0.6 0.6
0.4940 0.2840 0.5560
1 0.6940 0.7410
0.3010 0.7450 0.9330
0.7350 0.0780 0.1840];
colororder(newcolors)
legendString = "N = " + string(N);
plot_T = plot(K,C_Total_up,'-O','LineWidth',2);
grid on
title('Total Capacity of the System')
xlabel('Number of Users')
ylabel('Total Capacity (bit/s/Hz)')
legend(plot_T,legendString)
figure(2)
newcolors = [0 0.4470 0.7410
0.8500 0.3250 0.0980
0.9290 0.6940 0.1250
0.25 0.80 0.54
1 0.4470 0.7410
0.7 0.6 0.6
0.4940 0.2840 0.5560
1 0.6940 0.7410
0.3010 0.7450 0.9330
0.7350 0.0780 0.1840];
colororder(newcolors)
legendString = "K = " + string(K);
plot_L = plot(N,C_Total_up,'-O','LineWidth',2);
grid on
title('Total Capacity of the System')
xlabel('Number of Elements')
ylabel('Total Capacity (bit/s/Hz)')
legend(plot_L,legendString)

2 个评论

Can you also post the error message that you see? And the input file you are reading, or a sample of it?
How could we possibly know without the two files, C_Total_1.txt , C_Total_2.txt, that you forgot to attach? Please attach them after reading this:
All I can guess is that the file is not in the current folder or on the search path.

请先登录,再进行评论。

 采纳的回答

Cris LaPierre
Cris LaPierre 2022-2-3
I modified your code to be able to run here. There is no error message, and the plots appear. The most likely reason for your error is what ImageAnalyst said: your files were not in the path you specified: C:\Users\tripo\Documents\Total_April_Capacity\ART
Double check your path.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Signal Integrity Kits for Industry Standards 的更多信息

产品

版本

R2021b

标签

Community Treasure Hunt

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

Start Hunting!

Translated by