Filter löschen
Filter löschen

problem with entering variables in a function

1 Ansicht (letzte 30 Tage)
Achchuthan Ganeshanathan
Achchuthan Ganeshanathan am 8 Mär. 2013
function [ output_args ] = Newfunction( h )
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
if 105<h<120
warningMessage = sprintf('Warning: your velocity = %f\nYou may stall!', h);
uiwait(warndlg('Approaching Stall'));
elseif 100<h<105;
warningMessage = sprintf('Warning: your velocity = %f\nYou may stall!', h);
uiwait(warndlg('Close to stall'));
elseif h<100
warningMessage = sprintf('Warning: your velocity = %f\nYou may stall!', h);
uiwait(warndlg('STALL'));
end
end
**This is my function but i keep getting this error ??? Input argument "h" is undefined.
Error in ==> Newfunction at 5 if 105<h<120

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 8 Mär. 2013
Bearbeitet: Azzi Abdelmalek am 8 Mär. 2013
Use
if 105<h & h<120
and
elseif 100<h & h<105
  10 Kommentare
Achchuthan Ganeshanathan
Achchuthan Ganeshanathan am 8 Mär. 2013
Thankyou for helping me btw.. this is a part of my final year project at university and I have a deadline in 2 weeks to get it all up and running.. thankyou so much
Achchuthan Ganeshanathan
Achchuthan Ganeshanathan am 8 Mär. 2013
It is working now thankyou :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Ruben
Ruben am 8 Mär. 2013
where and how do you call your function? for example if h = 100, you should call it like this:
Newfunction( 100 )
or
h=100;
Newfunction(h)
  4 Kommentare
Achchuthan Ganeshanathan
Achchuthan Ganeshanathan am 8 Mär. 2013
do i have to assign this value in my GUI function. because I have assigned a value for h and wrote the function but still keep getting error messages
Ruben
Ruben am 8 Mär. 2013
as I see it now, you have assigned a value for h, but you're not supplying it to the function you wrote. There are two ways to overcome this.
1) supply the h as an input to your function every time you call it by calling your function like this: Newfunction(h) instead of: Newfunction
2) convert your function to a script. scripts don't require input, but are able to use all the current variables.
I'm no GUI-guru, so I don't know what is the best approach for your problem

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Environment and Settings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by