How to save the values of (x,C) in file 1 and (x,y) in file 2 to plot them in file 3.. the description in the code below
2 次查看(过去 30 天)
显示 更早的评论
% file 1
clc;
clear;
x=[1 3 2 5 8]
for i=1:10
C=i*(x);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% file 2
clc;
clear;
y=[2 3 1 6 8]
or i=1:10
C=i*(x);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%
% file 3
plot(x,C)
hold on
plot(y,C)
采纳的回答
KSSV
2021-6-11
% file 1
clc;
clear;
x=[1 3 2 5 8] ;
C = zeros(10,length(x)) ;
for i=1:10
C(i,:)=i*x;
end
writematrix(C,'file1.txt') ;
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% file 2
y=[2 3 1 6 8] ;
C = zeros(length(y),10) ;
for i=1:10
C(i,:)=i*y;
end
writematrix(C,'file2.txt') ;
%%%%%%%%%%%%%%%%%%%%%%%%%%
% file 3
C1 = importdata('file1.txt') ;
x = data(:,1) ;
C2 = importdata('file2.txt') ;
y = data(:,1) ;
plot(x,C1)
hold on
plot(y,C2)
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!