필터 지우기
필터 지우기

incorrect dimensions for matrix multiplication in piecewise function in matlab

조회 수: 3 (최근 30일)
João
João 2023년 3월 22일
편집: Torsten 2023년 3월 22일
This is what I am trying to implement in Matlab:
where vi = sin(2*pi*1000*t) and VD = 0.72
These are my commands:
>>t = 1:1000
>>t/1000
>>vi = sin(2*pi*1000*t)
>>vo = piecewise(vi<0.72, 0, vi>0.72, (vi-0.72)*exp(-t))
However, I get this error:
Error using * Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of rows in the second matrix. To perform elementwise multiplication, use '.*'.
I have no idea what I am doing wrong, any help?

답변 (1개)

Torsten
Torsten 2023년 3월 22일
편집: Torsten 2023년 3월 22일
tau = 1.0;
V_D = 0.72;
vi = @(t) sin(2*pi*t);
f = @(t) max(vi(t)-V_D,0).*exp(-t/tau);
t = 0:0.01:2*pi;
plot(t,f(t))

카테고리

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

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by