Equation- Divide by Vector

조회 수: 4 (최근 30일)
Iason
Iason 2014년 3월 14일
답변: Benjamin Avants 2014년 3월 14일
Hello, I`m a beginner and I would like to calculate the equation [Sd(t)=ag S 2.5 Tc/q T] for values of Tc<=T<=Td However, T is a vector and I don`t know how to divide an vector and make the results in a final vector form. This is my code:
clc;clear all; agd=0.24*9.81; S=1.15;
Tb=0.2; S=1.15; Tc=0.6; Td=2; q=2;
for T3=Tc:0.02:Td; M=agd*S*2.5*Tc/q; Sd3=M/T3 end
In this way I get the results, but not in a vector form.
Thanks in advance

채택된 답변

Benjamin Avants
Benjamin Avants 2014년 3월 14일
Your code is a little hard to read... I would suggest not stringing commands together on the same line.
That being said...
You will want to use the .* and ./ operators. They will perform operations on each element of an array and return an array.
Example:
agd = 0.24*9.81;
S = 1.15;
Tb = 0.2;
Tc = 0.6;
Td = 2;
q = 2;
T3 = Tc:0.02:Td;
constant = (agd * S *2.5 * Tc / q);
Sd3 = constant ./ T3;
Solving for the constant first will reduce the number of computations MATLAB has to do to return your answer. Not so important here, but useful with large data sets.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by