Change the sign of a Vector over N intervals
1 回表示 (過去 30 日間)
古いコメントを表示
Hi everyone,
I'm new to Matlab, my question may be super easy….I want to get a vector (Ytot ) witch is composed of the same function but with different signs set on différents intervals , that's not a problem for 2 or 3 vectors , but i dont know how to manage it with n intervals ?
This is an example :
Y = function_example;%%%% (define on 1 : 100)
T = [1; 9 ;17 ;...….89; 100] ;%%%(for example 24values)
A = [-1; 1 ; 1; ......…..-1]; %%% signs for each intervals
Y1 = -1*Y(1:9); %%% equal to Y between 1 and 9, and equal to 0 between 10 and 100
Y2 =1*Y(9:17);
Y24 =-1*Y(89:100);
t1 = (1: 1: 9);
t2 = (9: 1: 17);
tn = (89 :1: 100);
Ttot = [t1 +t2+...t24];
Ytot = [Y1 + Y2 + ….Y24];
0 件のコメント
回答 (1 件)
Rafael Hernandez-Walls
2021 年 3 月 31 日
Use something like this:
Y=rand(1,20);
d=[1:4,8:12,17:20];
Y(d)=-Y(d)
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!