Hello, I receive this error

2 次查看(过去 30 天)
Hello, I have a folder and i have inside two m files and three .xlsx excel files. My first code 'Graph_Preprocessing_and_Visualization' works fine. Now, i want with some way to run my first script as a function in my second code 'Simulink_Configuration_Model'. My function in the second code has the same name with my first code. Here is my code:
set(0,'RecursionLimit',2000)
clear
close_system
clc
%%%Open simulink model
fic1='filname'
new_system('filname')
open_system('filname')
%%%Set Graph_Preprocessing_and_Visualization function parameters
bus_filename='Buscoords.xlsx';
lines_filename='Lines.xlsx';
loads_filename='Loads.xlsx';
Visualization_flag=1;
% Generate the new reduced system
[Bus_final,lines_final,line_type,Adjacency_matrix]=Graph_Preprocessing_and_Visualization(bus_filename,lines_filename,loads_filename,Visualization_flag)
A_ini=Bus_final; %%%Bus Final
Lines=lines_final(:,1:2) %%%Lines Final only the connections without the length
Here is my error:
Attempt to execute SCRIPT
Graph_Preprocessing_and_Visualization as a
function:
C:\Users\user\Desktop\mtlb\bin\New
folder2\Graph_Preprocessing_and_Visualization.m
Error in Simulink_Model_Configuration
<<>>
(line 16)
[Bus_final,lines_final,line_type,Adjacency_matrix]=Graph_Preprocessing_and_Visualization(bus_filename,lines_filename,loads_filename,Visualization_flag)

采纳的回答

GEEVARGHESE TITUS
GEEVARGHESE TITUS 2017-10-11
When the problem is because ofexecuting the line [Bus_final,lines_final,line_type,Adjacency_matrix]=Graph_Preprocessing_and_Visualization(bus_filename,lines_filename,loads_filename,Visualization_flag)
It seems you have not defined the function Graph_Preprocessing_and_Visualization prior.
  3 个评论
Walter Roberson
Walter Roberson 2017-10-11
You do already have
C:\Users\user\Desktop\mtlb\bin\New folder2\Graph_Preprocessing_and_Visualization.m
on your path, but it is not coded as a function file.
You should check whether C:\Users\user\Desktop\mtlb\bin\New folder2\Graph_Preprocessing_and_Visualization.m happens to be on your path by accident, or whether it is some junk file that you can delete, or if you accidentally tried to use the same name Graph_Preprocessing_and_Visualization for two different purposes
Antonis Marinou
Antonis Marinou 2017-10-11
Thank you very much, you are absolutely right, i did not coded my first code as a function. Now it is working! Thank you mr Walter Roberson

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by