NOT ENOUGH INPUT ARGUMENTS

function BPBMI_plot(Sex, LastName, loc_data)
Weight = loc_data(:,2);
Height = loc_data(:,3);
BP = loc_data(:,4);
%convert Height from centimeters to meters
Height = Height / 100 ;
% Calculate BMI
bmi = Weight / (Height).^2 ;
figure;
hold on
%plot data on left side
yyaxis left
%plot bmi
bar(bmi, 'W')
ylabel('BMI')
%plot data on right axis
yyaxis right
%plot Blood Pressure
plot(BP, 'r-+');
%plot Weight
plot(Weight, 'B-O')
% x label
xticks(1:12)
xticklabels({'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep', 'Oct','Nov','Dec'})
xlabel('Month')
%title
title(['Bmi and Relationship to Blood Pressure and Weight for ' num2str(LastName,2) ' sex ' num2str(Sex,2) ])
%legend
legend('BMI', 'blood Pressure','Weight')
hold off
end

回答 (1 件)

KSSV
KSSV 2021 年 12 月 10 日

0 投票

You might be running the function striaght away using f5 or hitting run button. You need to provide the inputs to the function and then call the function.
Sex = define your value ;
LastName = define your value ;
loc_data = define your value ;
% Now call the function
BPBMI_plot(Sex, LastName, loc_data) ;

7 件のコメント

Khaled Awda
Khaled Awda 2021 年 12 月 10 日
all these values was defined by using other scripts
Walter Roberson
Walter Roberson 2021 年 12 月 10 日
But are you passing the values in? Inside of a function, Matlab will never look in the base workspace to see if a variable with the same name happens to be defined.
Khaled Awda
Khaled Awda 2021 年 12 月 10 日
yes i am passing using a main script that connects all scripts together
Khaled Awda
Khaled Awda 2021 年 12 月 10 日
with functions
Walter Roberson
Walter Roberson 2021 年 12 月 10 日
Do you have a line of code that looks similar to
BPBMI_plot(Sex, LastName, loc_data) ;
? If you do, is it the only place you mention BPBMI_plot?
If the call is within a function is it possible that you are not passing all needed parameters to that function?
Khaled Awda
Khaled Awda 2021 年 12 月 10 日
i have 4 different file
sex
lastname and loc_data
BPBMI
main - calls all functions in the same order
sex
lastname and loc_data
BPBMI
Walter Roberson
Walter Roberson 2021 年 12 月 10 日
I suggest that you open a support case with Mathworks, as you are not able to share your code with us.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

質問済み:

2021 年 12 月 10 日

コメント済み:

2021 年 12 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by