Unrecognized function or variable in live script
Mostra commenti meno recenti
I am running the following simple live script in Matlab Online:
a = 1
b(2)
function out = b(o)
out = a + o;
end
and I get the following error:

I am not sure how to make the function b use the variable a in this scenario. One of my postulations was that this is only a Matlab Online issue, but I can't verify this. I also tried using global a but it did not work.
Risposta accettata
Più risposte (1)
Walter Roberson
il 8 Mag 2021
driver
function driver
a = 1
b(2)
function out = b(o)
out = a + o;
end
end
Shared variables require nested functions.
1 Commento
Jaafar Rammal
il 8 Mag 2021
Categorie
Scopri di più su Logical in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!