Hello, I receive this error

조회 수: 2 (최근 30일)
Antonis Marinou
Antonis Marinou 2017년 10월 11일
댓글: Antonis Marinou 2017년 10월 11일
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