Input data from another script
显示 更早的评论
I have a data x with an increment of x = 1:1:100 and I wan to input it to another script such that the another script receive x = 1 to x = 100 instead of the whole array.
回答(1 个)
KSSV
2022-3-11
x = 1:1:100 ;
for i = 1:length(x)
xi = x(i) ;
% input xi to your function and do what you want
end
4 个评论
Apo Li
2022-3-11
KSSV
2022-3-11
Show us the full code.
Apo Li
2022-3-11
KSSV
2022-3-11
A BIG NO......
What is untitled1??? Come on.....you have to write it like a function, with input x (a single number) and do somehting and take output.
% EXample
clear all
clc
x = 1:1:100 ;
for i = 1:length(x)
xi = x(i) ;
b = Add_three(xi) ;
end
function theoutput = Add_three(theinput)
% do whay you want
theoutput = theinput+3 ; % as a demo I have added three
end
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!