Write a MATLAB program to generate data for a straight line
Write a MATLAB program to generate data for a straight line whose y-intercep is 5 and slope is +3. Use [0, 10] interval for the x-values and calculate corresponding y values to represent the line. Use the plot command to plot the line with appropriate abscissa and ordinate values and chart title
Solution
x=0:10; % x-values with 0,1 2,...10
slope=3;
yintercept=5;
y=slope.*x+yintercept;
plot(x,y)
title(\'Straight Line\')
axis([0 10 0 40])
![Write a MATLAB program to generate data for a straight line whose y-intercep is 5 and slope is +3. Use [0, 10] interval for the x-values and calculate correspon Write a MATLAB program to generate data for a straight line whose y-intercep is 5 and slope is +3. Use [0, 10] interval for the x-values and calculate correspon](/WebImages/26/write-a-matlab-program-to-generate-data-for-a-straight-line-1069175-1761559782-0.webp)