Solving MATLAB Problem: Sines, Cosines & Tangent Arrays

  • Thread starter Thread starter Erkan Tur
  • Start date Start date
  • Tags Tags
    Matlab
Click For Summary
SUMMARY

The discussion focuses on solving a MATLAB problem involving the evaluation and storage of sine, cosine, and tangent values for angles ranging from 0 to 260 degrees in increments of 10 degrees. Users are instructed to create separate arrays for sine and cosine values, plot these using MATLAB's built-in functions, and compare results. Key issues include correctly defining the tangent array using the sine and cosine arrays, rather than directly calculating tangent values from angles. The consensus emphasizes that the tangent should be computed as the ratio of the sine to cosine arrays.

PREREQUISITES
  • Familiarity with MATLAB programming
  • Understanding of trigonometric functions: sine, cosine, and tangent
  • Knowledge of array manipulation in MATLAB
  • Experience with MATLAB plotting functions
NEXT STEPS
  • Learn how to define custom functions in MATLAB for sine and cosine
  • Research MATLAB array operations for element-wise calculations
  • Explore MATLAB's built-in plotting functions for visualizing data
  • Study the differences between degrees and radians in trigonometric calculations
USEFUL FOR

This discussion is beneficial for MATLAB users, students learning programming and trigonometry, and anyone interested in data visualization and mathematical computations in MATLAB.

Erkan Tur
Messages
5
Reaction score
1
Moved from a technical forum, so homework template missing.
Hello everyone, I've stuck on a problem, and I need help

Problem:
1: a) Evaluate and store the sine and cosine values of the values from 0 to 260 10 by 10 and store them to the separated arrays called sines and cosines before plotting the sinusoidal graphs of these arrays, b) Evaluate the Tangent of these values by simply using these arrays c) Use the built-in sin and cos functions to evaluate same results and compare the results with yours, explain the reason of the differences

My Steps on Solving the Problem
I've wrote the code, like this:

clear

sines = [0:10:260]
sin(sines)
subplot(1, 2, 1)
stem(sines,sind(sines)), grid on

hold on

cosines = [0:10:260]
cos(cosines)
subplot(1, 2, 2)
stem(cosines, cosd(cosines)), grid on

Problems I've encountered:
I was not able to define sine and cosine function, I've used the built-in functions for sine and cosine functions,
And I need help on defining new tangent array. I need to know, should I define the values for tangent as sin(n)/cos(n), or can I directly multiply arrays in order to get that done?

Thank you in advance
 
Physics news on Phys.org
Your arrays sines and cosines should contain the sin and cos, not the angles.

My guess is that in the first part, you need to input the values of sin and cos by hand.

The tangent should be obtained from the sines and cosines arrays.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
4
Views
2K
  • · Replies 21 ·
Replies
21
Views
3K
  • · Replies 23 ·
Replies
23
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K