Hello, I receive this error

2 views (last 30 days)
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)

Accepted Answer

GEEVARGHESE TITUS
GEEVARGHESE TITUS on 11 Oct 2017
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 Comments
Walter Roberson
Walter Roberson on 11 Oct 2017
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 on 11 Oct 2017
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

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!