0% found this document useful (0 votes)
33 views

Graph Rat

This document contains MATLAB code for a program that takes user input for grid sizes and axis ranges to calculate and display the number of squares needed to cover the given axis ranges using the specified grids. It prompts the user for input values, calculates grid side lengths based on the inputs, prompts the user to select grid sizes for the x and y axes, and uses those selections to calculate and display the approximate number of excess squares needed at each axis.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Graph Rat

This document contains MATLAB code for a program that takes user input for grid sizes and axis ranges to calculate and display the number of squares needed to cover the given axis ranges using the specified grids. It prompts the user for input values, calculates grid side lengths based on the inputs, prompts the user to select grid sizes for the x and y axes, and uses those selections to calculate and display the approximate number of excess squares needed at each axis.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

C:\matlabR12\work\graphrat.

m
April 9, 2010

Page 1
10:21:01 PM

clc
clear all
disp('welcome to graph rationaler')
g1=input('grid size large (g1)=');
g2=input('grid size small (g2)=');
x1=input('upper value of x =');
x2=input('lower limit of x =');
y1=input('upper value of y =');
y2=input('lower value of y =');
diffx=x1-x2;
diffy=y1-y2;
v1=g1/diffx;
fprintf('grid side one value for x=%f\n',v1)
v2=g2/diffx;
fprintf('grid side two value for x=%f\n',v2)
v3=g1/diffy;
fprintf('grid side one value for y=%f\n',v3)
v4=g2/diffy;
fprintf('grid side two value for y=%f\n',v4)
cx=input('enter the choice for x=');
cg1=input('enter the corresponding grid side (" if long side g1 else g2")=
');
cy=input('enter the choice for y=');
clc
fprintf('your choice for x axis(per squar)=%f\n',cx)
fprintf('your choice for y axis(per squar)=%f\n',cy)
if 'cg1=g1'
cg2=g2;
else cg2=cg1;
end
fprintf('x axis falls to grid=%f\n',cg1)
fprintf('y axis falls to grid=%f\n',cg2)
if 'cg1=g1'
a1=ceil((cx*g1-diffx)/g1);
a2=ceil((cy*g1-diffy)/g1);
else a1=ceil((cx*g2-diffx)/g2);
a2=ceil((cy*g2-diffy)/g2);
end
fprintf('appr: excces squars at x axis=%f\n',a1)
fprintf('appr: excces squars at y axis=%f\n',a2)
disp('NOVA /2010')

You might also like