Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

MATLAB :How to program with MATLAB

1 visualizzazione (ultimi 30 giorni)
Lan
Lan il 7 Mar 2015
Chiuso: MATLAB Answer Bot il 20 Ago 2021
When a>90°,the value of L is 9; when a<90°,the value of L is 90; MATLAB? :How to program with MATLAB

Risposte (2)

Star Strider
Star Strider il 7 Mar 2015
One way:
L = @(a) [9*(a>90) + 90*(a<90) + 0*(a==90)];
L_test = L([45 135 90]);

James Tursa
James Tursa il 7 Mar 2015
You should probably review the basics of MATLAB. E.g.,
As for your particular request, simply taking your words and forming them into pseudo-code:
When a>90°
the value of L is 9;
when a<90°,
the value of L is 90
Turning each line into MATLAB syntax yields:
if( a > 90 )
L = 9;
elseif( a < 90 )
L = 90;
end
Then note that you have not covered the case where a == 90 exactly.

Questa domanda è chiusa.

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by