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 Ansicht (letzte 30 Tage)
% 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)

Akzeptierte Antwort

KSSV
KSSV am 11 Jun. 2021
% 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)

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by