Info
Cette question est clôturée. Rouvrir pour modifier ou répondre.
i have one function file and m file now i give values of x(1) and x(2) in function file which update in m fille and run
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
function y=fitfund1(x) %for this we give two values of x(1) and x(2)
sys= xlsread('IEEEE1.xlsx'); %this is excel file
sys(x(2),7)=sys(x(2),7)-x(1);
sys %this updated value excel file with x(1) and x(2)
lflow1 % this is mfile which run with this "system' excel sheet
end
now lflow1 is mfile which is run with that updated system excel sheet
frombus = sys(:,1)';
tobus = sys(:,3)' ;
when run this code system is unknown for this vaue
0 commentaires
Réponses (2)
ES
le 22 Mar 2017
1. dont use system in our code. system is a keyword in MATLAB intended to do something else.
2. and fitfun is a function. so the value in system is visible to its workspace only. This will not be accessible by lflow1.
So a) either make lflow1 as a function and pass 'system1' to it. or b) make fitfun to write value of 'system1' into base workspace so that lflow1 can access it as you have done now.
2 commentaires
ES
le 22 Mar 2017
Modifié(e) : ES
le 22 Mar 2017
Solution 1: a) make lflow1 as a function and pass 'sys' to it.
.m
function y=fitfund1(x) %for this we give two values of x(1) and x(2)
sys= xlsread('IEEEE1.xlsx'); %this is excel file
sys(x(2),7)=sys(x(2),7)-x(1);
sys %this updated value excel file with x(1) and x(2)
lflow1(sys) % this is mfile which run with this "system' excel sheet
end
lflow1.m
function lflow1(sys)
frombus = sys(:,1)';
tobus = sys(:,3)' ;
end
4 commentaires
ES
le 22 Mar 2017
Please try solution 2.make fitfun to write value of 'system1' into base workspace so that lflow1 can access it as you have done now.
.m
function y=fitfund1(x) %for this we give two values of x(1) and x(2)
sys= xlsread('IEEEE1.xlsx'); %this is excel file
sys(x(2),7)=sys(x(2),7)-x(1);
sys %this updated value excel file with x(1) and x(2)
assignin('base', 'sys', sys) %This creates a variable with name sys in base workspace with the same value of sys calculated above
lflow1 % this is mfile which run with this "system' excel sheet
end
lflow1.m [This remains as you had done originally. Since sys is now available in workspace, lflow1 can access sys, and frombus and tobus will also be available in the workspace.]
frombus = sys(:,1)';
tobus = sys(:,3)' ;
Cette question est clôturée.
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!