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 CenterFile Exchange에서 Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by