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

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site