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

1 回表示 (過去 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
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 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by