function with multiple intervals
Show older comments
Dear all, why i cant plot and export the result of my equation ?
clc, clear all, close all
x = (0:0.4:4)'
%
if 0<= x && x< 1
y = 2.*x
disp('y1')
elseif 1<= x && x< 2
y = 2
disp('y2')
elseif 2<= x && x<3
y = (3/x).^(1/4)
disp('y3')
elseif 3<= x && x<=4
y = ((3/x).^(1/4))*((x/4).^(1/3))
disp('y4')
end
plot(x,y)
%
M = [x; y];
%
fileID = fopen('out.txt','w');
fprintf(fileID,'%6s %12s\n','x','y');
fprintf(fileID,'%6.2f %12.8f\n',M);
fclose(fileID);
Thanks
Accepted Answer
More Answers (0)
Categories
Find more on Data Types in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!