Why doesn't it work ?

Why doesn't it work ?
I don't understand

3 件のコメント

dpb
dpb 2023 年 1 月 15 日
Paste your code as text and format it with the "Code" button instead of as image...
But, you are missing the difference between array and element-wise multiplication. See the times, .* documentation for all the info...the "dot" operators are key.
David
David 2023 年 1 月 15 日
s = 1.25;
t1 = 0:0.01:pi/2;
t2 = pi/2:0.01:pi;
t = [t1 t2];
p = [(4*(sin(2*t1))(sin(2*t1)))*exp(-(t/s)(t/s))+2) (4*(sin(2*t2))*(sin(2*t2)))*exp(-t2/s)+2)];
figure()
plot(t ,p)
xlabel("yura")
ylabel("elad")
title("lauren hazout")
dpb
dpb 2023 年 1 月 15 日
That's better, thanks, but why not edit the original Q? and put the code there? Will it not let you edit your own Q?.
But, you've not taken the advice to heed -- the problem is still that you're not using the "dot" operators...

サインインしてコメントする。

回答 (2 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2023 年 1 月 15 日

0 投票

s = 1.25;
t1 = 0:0.01:pi/2;
t2 = pi/2:0.01:pi;
t = [t1 t2];
x1=4*sin(2*t1).*sin(2*t1).*exp(-(t1/s))+2;
x2=4*sin(2*t2).*sin(2*t2).*exp(-(t2/s))+2;
p =[x1 x2];
plot(t,p)
xlabel('yura'); ylabel('elad')
title('lauren hazout')
VBBV
VBBV 2023 年 3 月 2 日

0 投票

s = 1.25;
t1 = 0:0.01:pi/2;
t2 = pi/2:0.01:pi;
t = [t1 t2];
p=[4*sin(2*t1).^2.*exp(-(t1/s).^2)+2 4*sin(2*t2).^2.*exp(-(t2/s))+2]
p = 1×316
2.0000 2.0016 2.0064 2.0144 2.0255 2.0398 2.0572 2.0776 2.1011 2.1275 2.1569 2.1890 2.2239 2.2615 2.3017 2.3443 2.3894 2.4367 2.4862 2.5378 2.5913 2.6466 2.7036 2.7621 2.8221 2.8833 2.9457 3.0091 3.0734 3.1384
%
plot(t,p)
xlabel('yura'); ylabel('elad')
title('lauren hazout')
As the error suggests, use element wise powee .^

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

質問済み:

2023 年 1 月 15 日

回答済み:

2023 年 3 月 2 日

Community Treasure Hunt

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

Start Hunting!

Translated by