Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can i save the outputs of a function inside that function so i can recall that function in another script and plot with it output ???

1 回表示 (過去 30 日間)
Hatef
Hatef 2014 年 1 月 7 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
function [x] = compute(W, k1, k2, d)
x1 = W / k1; x2 = ( W + 2 * k2 * d ) ./ ( k1 + 2 * k2 ); k1 = 10000; k2 = 15000; d = 0.1;
if x1 < d;
x = x1;
else x = x2;
end
this is my first function, after i set the value W i get an output, now i want to save that output inside this function so i can use it in my next script which is this one:
W = 0:50:3000;
k1 = input ('Please enter a value for k1=', 's');
k1 = str2num(k1);
a = isempty(k1);
while a == 1;
k1 = input('Wrong Input!!! Please enter a value for k1=' , 's');
k1 = str2num(k1);
a = isempty(k1);
end
while a == 0;
k2 = input('Please enter a value for k2=','s');
k2 = str2num(k2);
b = isempty(k2);
while b == 1;
k2 = input('Wrong Input!!! Please enter a value for k2=','s');
k2 = str2num(k2);
b = isempty(k2);
end
while b == 0;
d = input('Please enter a value for d=','s');
d = str2num(d);
c = isempty(d);
while c == 1;
d = input('Wrong Input!!! Please enter a value for d=','s');
d = str2num(d);
c = isempty(d);
end
if c == 0;
end
break;
end
break;
end
x = compute(W, k1, k2, d);
plot(W, x);
xlabel('Distance(m)');
ylabel('Weight(N)');

回答 (0 件)

この質問は閉じられています。

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by