Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

Cant figure out why my program isnt working

1 view (last 30 days)
Cory
Cory on 13 Feb 2012
Closed: MATLAB Answer Bot on 20 Aug 2021
% ENGR 1120 Sec.10
% 2/7/12
% This program
clear,clc
filename=input('Enter file name in quotes');
data=load(filename);
dist_trav=data(:,1); %ft
direction=data(:,2);
%
%
% Convert clocking to angles
angle = rem((60 - (direction - 1) * 30) + 360, 360) %degrees
%
% Plot graph of results
plot(dist_trav,direction)
title('Homework2')
xlabel('Distance to travel')
ylabel('Direction to travel'),grid
The file that is the input contains two columns of number data both 1x5
  6 Comments
Jan
Jan on 13 Feb 2012
@Cory: Please be so kind and post a *complete copy* of the error message. We need 1. the line, which causes the error, 2. the error message itself, 3. size/type/contents of the used variables, if they matter.
The code you've posted does not contain the term "hmwrk2" and it is not clear which command causes the index overflow.
Cory
Cory on 13 Feb 2012
It says undefined function or method 'hmwrk2' after i enter the filename when im trying to run the script
However, It says index exceeds matrix dimesnions if i just copy paste the steps in to the program
the file contains column#1 1.2,1.6,1.2,1.6,1.2 (ft) column#2 9,12,3,12,9 (clock face)

Answers (2)

William
William on 13 Feb 2012
Just giving this a glance. Matlab works in Radians. There are certain commands you can specifily use to get matlab to work in degrees but I do not see any of them here.
  1 Comment
Cory
Cory on 13 Feb 2012
THhe problem:
You have been given a set of ASCII data files that contain directions for laying out
patterns in a field. The data files contain in the first column a distance to travel and in the second
column a direction heading. Unfortunately, the person who created the data did not have a good
understanding of orienteering and the direction headings are given as referenced to a clock face.
The pattern begins at the origin of a Cartesian coordinate system with the person facing 12
o’clock, see the figure below. The figure shows an example of the first step in the pattern being
a distance of 1.5 feet in the direction of 7 o’clock. All direction headings are given in terms of
this clock orientation.
The distance values
given are in feet.
There are 5 data files
provided on the L
drive for testing of the
program.
Write a script
file that will allow the
user to input from the
keyboard the filename
of the file that they
wish to analyze. Load
only that ONE data file
and plot the resulting
pattern. Once each
point forming the pattern has been located, find and designate on the plot which of the resulting
nodes was the farthest away from the origin. Also find and designate the center of the pattern as
defined to occur at the coordinate location corresponding to (average x, average y). When
plotting the resulting pattern on the Cartesian coordinate system, set the axes limits
appropriately.
Submit: A flowchart, a copy of the script file, and ONE example output screen that processes
ONE data file.

Walter Roberson
Walter Roberson on 13 Feb 2012
You are trying to run the script file by naming the input file on the command line. Don't do that. Just run the script file and let it prompt you for the input file.
  1 Comment
Cory
Cory on 13 Feb 2012
Im new to this. I dont quite understand what your saying

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!