First value of an array does not display with a decimal
I am trying to print an array which display the values of x y and z on every change of x and z, but the first value os always formated a different way if z is an integer. Here is the awnser I get:
And here is my code:
zp=input(‘Įveskite pradinę z vertę: ‘);
zg=input(‘Įveskite galutinę z vertę: ‘);
hz=input(‘Įveskite z vertės pokytį: ‘);
xp=4;
hx=0.3;
x=xp;
disp(‘ x y z’);
for z=zp:hz:zg
if z>=x
y=sin(x).*cos(x);
else
y=log10(xp).*log(z);
end
disp([x y z]);
x=x+hx;
endI am trying to print an array which display the values of x y and z on every change of x and z, but the first value os always formated a different way if z is an integer. Here is the awnser I get:
And here is my code:
zp=input(‘Įveskite pradinę z vertę: ‘);
zg=input(‘Įveskite galutinę z vertę: ‘);
hz=input(‘Įveskite z vertės pokytį: ‘);
xp=4;
hx=0.3;
x=xp;
disp(‘ x y z’);
for z=zp:hz:zg
if z>=x
y=sin(x).*cos(x);
else
y=log10(xp).*log(z);
end
disp([x y z]);
x=x+hx;
end I am trying to print an array which display the values of x y and z on every change of x and z, but the first value os always formated a different way if z is an integer. Here is the awnser I get:
And here is my code:
zp=input(‘Įveskite pradinę z vertę: ‘);
zg=input(‘Įveskite galutinę z vertę: ‘);
hz=input(‘Įveskite z vertės pokytį: ‘);
xp=4;
hx=0.3;
x=xp;
disp(‘ x y z’);
for z=zp:hz:zg
if z>=x
y=sin(x).*cos(x);
else
y=log10(xp).*log(z);
end
disp([x y z]);
x=x+hx;
end display, format, decimal, array MATLAB Answers — New Questions









