Change the sign of a Vector over N intervals
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Rafael Hernandez-Walls
am 31 Mär. 2021
Use something like this:
Y=rand(1,20);
d=[1:4,8:12,17:20];
Y(d)=-Y(d)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!