Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Cant figure out why my program isnt working

조회 수: 1 (최근 30일)
Cory
Cory 2012년 2월 13일
마감: MATLAB Answer Bot 2021년 8월 20일
% 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
Jan
Jan 2012년 2월 13일
@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 2012년 2월 13일
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)

답변 (2개)

William
William 2012년 2월 13일
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
Cory
Cory 2012년 2월 13일
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 2012년 2월 13일
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
Cory
Cory 2012년 2월 13일
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!

Translated by