How to make a text file from functions
x = 1
y = 1
myFile = fopen(‘myValues.txt’, ‘w’)
fprintf(myFile, "X LengthtY Lengtht Hypot LengthttPerimeterttArean")
for i = 1:5
for j = 1:5
myHypot = hValue(i,j)
myPerim = pValue(i,j)
myArea = aValue(i,j)
fprintf(myFile, string(i) + "ttt" + string(j) + "tttt" + string(myHypot) + "ttt" + string(myPerim) + "ttt" + string(myArea) + "n")
end
end
function hValue = hValue(xValue,yValue)
hValue = sqrt(xValue.^2+yValue.^2);
end
function pValue = pValue(xValue,yValue)
pValue = (xValue + yValue + (sqrt(xValue.^2+yValue.^2)));
end
function aValue = aValue(xValue,yValue)
aValue = 0.5*xValue*yValue;
endx = 1
y = 1
myFile = fopen(‘myValues.txt’, ‘w’)
fprintf(myFile, "X LengthtY Lengtht Hypot LengthttPerimeterttArean")
for i = 1:5
for j = 1:5
myHypot = hValue(i,j)
myPerim = pValue(i,j)
myArea = aValue(i,j)
fprintf(myFile, string(i) + "ttt" + string(j) + "tttt" + string(myHypot) + "ttt" + string(myPerim) + "ttt" + string(myArea) + "n")
end
end
function hValue = hValue(xValue,yValue)
hValue = sqrt(xValue.^2+yValue.^2);
end
function pValue = pValue(xValue,yValue)
pValue = (xValue + yValue + (sqrt(xValue.^2+yValue.^2)));
end
function aValue = aValue(xValue,yValue)
aValue = 0.5*xValue*yValue;
end x = 1
y = 1
myFile = fopen(‘myValues.txt’, ‘w’)
fprintf(myFile, "X LengthtY Lengtht Hypot LengthttPerimeterttArean")
for i = 1:5
for j = 1:5
myHypot = hValue(i,j)
myPerim = pValue(i,j)
myArea = aValue(i,j)
fprintf(myFile, string(i) + "ttt" + string(j) + "tttt" + string(myHypot) + "ttt" + string(myPerim) + "ttt" + string(myArea) + "n")
end
end
function hValue = hValue(xValue,yValue)
hValue = sqrt(xValue.^2+yValue.^2);
end
function pValue = pValue(xValue,yValue)
pValue = (xValue + yValue + (sqrt(xValue.^2+yValue.^2)));
end
function aValue = aValue(xValue,yValue)
aValue = 0.5*xValue*yValue;
end matlab MATLAB Answers — New Questions