How to list specific variable at all points except at certain values
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am currently writing a code where I am trying to figure out how to program a certain value for all inputs except at certain values. For example, if I am running trials starting at 0 and ending at 10, and would like an output of 5 for trails 0-4, and an output of 10 for all others, how would I go about coding that? And if possible, can it be set up to where all outputs do not need to manually be written, so if I decide to run more trials (either before 0 or after 10) it will autofill the new slots? Thanks for the help
0 comentarios
Respuestas (1)
Star Strider
el 12 de Dic. de 2021
I have no idea what the actual application is.
One option:
outpt = @(trial) ((trial >= 0) & (trial <= 4)).*5 + ((trial < 0) | (trial >= 5))*10;
x = -5:15;
figure
stem(x, outpt(x), 'filled')
grid
axis([-5.5 10.5 -0.5 10.5])
xlabel('Trial')
ylabel('Output')
Experiment to get the desired results.
.
6 comentarios
Star Strider
el 12 de Dic. de 2021
I apologise, however this isn’t helpful.
I understand that you may understand the textbook description, however I don¹t. I’m still having a difficult time understanding both the input and the desired output.
Is there a way for you to download the data from the textbook website online and post it here with an explanation of what it is and what the desired output should be from it?
Just now, I don’t have a clue.
I would very much like to help, however I need more definitive information.
.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!