create a specific vector from excel file
Show older comments
I want create a zero vector (1*24) and according to the appliances like for 'lights' (in Excel file ) create A1 zero vector (1*24) ,start and end time shows that A1 zero vector replace power value of 0.5 between 18-24 in row vector but the condition is that this 0.5 values put only 6 places randomly between 18-24. And similarly for all appliances. Like PHEV A17 vector it should contain 2.5 power value at 20-21-22-23-24-1-2-3-4-5-6 only for 4 (hours ) place randomly at any place between 20-6 .
3 Comments
Jan
on 4 Aug 2017
I do not understand the question clearly. What are "lights (in Excel file)"? What are "appliances"? What is "PHEV A17"? What does "contain 2.5 power value at 20-21-22-23-24-1-2-3-4-5-6 only for 4 (hours ) place randomly at any place between 20-6" mean?
MUKESH KUMAR
on 4 Aug 2017
Accepted Answer
More Answers (1)
Jan
on 4 Aug 2017
All I understand from the question is: "0.5 values put only 6 places randomly between 18-24":
A1 = zeros(1, 24);
index = 18:24;
index = index(randperm(1:7, 6));
A1(index) = 0.5;
Easier:
A1 = zeros(1, 24);
A1(18:24) = 0.5;
A1(randi([18, 24], 1)) = 0;
I have no idea, what the rest of the question means.
4 Comments
MUKESH KUMAR
on 4 Aug 2017
MUKESH KUMAR
on 4 Aug 2017
MUKESH KUMAR
on 8 Aug 2017
Jan
on 9 Aug 2017
No, I do not understand it. "simillary for all appliances like for 'TV' (in Excel file )" What is a "appliance", what is "TV", what does "in Excel file" mean? What is an "A5 zero vector (1*24)"? "start and end time shows that A1 zero vector replace power value of 0.25 between 16-24"?
Sorry, I do not understand any sentence of the explanation. If KL#s answer solves your problem, it is not worth to explain it again.
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!