How to use the logspace function to create a vector of frequencies in Hz and not rad/s

조회 수: 9 (최근 30일)
Given frequencies f1 and f2, low and high respectively, in Hz, how can I use the logspace function to create a vector of frequencies in Hz?
If f1 is 0.087Hz and f2 is 20Hz, creating a vector:
A = logspace(1,2)
would be incorrect as logspace takes in inputs as rad/s, how can i use logspace using the same values in Hz?

채택된 답변

Dave B
Dave B 2021년 10월 26일
To get logarithmically spaced values between 0.087 and 20:
logspace(log10(.087), log10(20))
ans = 1×50
0.0870 0.0972 0.1086 0.1214 0.1356 0.1515 0.1693 0.1892 0.2114 0.2362 0.2639 0.2949 0.3295 0.3682 0.4114 0.4597 0.5136 0.5739 0.6412 0.7165 0.8006 0.8945 0.9995 1.1168 1.2479 1.3943 1.5580 1.7408 1.9452 2.1734
To be clear, logspace doesn't take inputs in rad/s or Hz, it just takes values. But it expects exponents that 10 would be raised to, and so you can use log10 to convert your values.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by