Hi there, I'm encountering an issue and would appreciate your guidance in resolving it.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Danikha Shyken
el 7 de Oct. de 2023
Comentada: Danikha Shyken
el 9 de Oct. de 2023
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1504759/image.png)
1 comentario
Dyuman Joshi
el 7 de Oct. de 2023
What if mode is not equal to " Boost " or " Buck "? What should be the value of the variables in that case?
You can either define the values or give an error message.
Respuesta aceptada
Image Analyst
el 7 de Oct. de 2023
mode is a built-in function. Don't use it as the name of your variable!!
Also, you need to initialize your variables before the if block in case neither of your conditions is met.
function [q1, q2, q3, q4] = ConverterControl(modeString, D)
q1 = nan;
q2 = nan;
q3 = nan;
q4 = nan;
% Trim off white space
modeString = strtrim(modeString);
if strcmpi(modeString, 'Boost') % Don't use spaces around Boost anymore. It's more robust this way.
%etc.
Or you could use contains with IgnoreCase=true if you're certain you'll never have Boost and Buck in the same modeString, and then if you use contains() you could eliminate strtrim().
Más respuestas (0)
Ver también
Categorías
Más información sobre C2000 Microcontroller Blockset en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!