現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
I want to create a matlab program to perform this operation and show the result in each operation in table
4 ビュー (過去 30 日間)
古いコメントを表示
X(i)=sumation of x(i-k)*f(k) Where i=1:200,k=1:i,f(k) is a function
21 件のコメント
Walter Roberson
2021 年 6 月 27 日
That looks like a convolution. See conv()
Note: you might need to fliplr(x)
Maha Ahmed
2021 年 6 月 27 日
I can't understand your answer, this is a summation loop with two counters on the product of two functions related to each other
Walter Roberson
2021 年 6 月 28 日
if x and f are functions then you should be using integral instead of summation, and you will find that you have matched the definition of convolution.
If f and x are vectors being indexed then what you have matches conv()
Maha Ahmed
2021 年 6 月 28 日
This is all the first task what should I do with (gui) ,i perform ft,rt with plot ,and operate Handel function to calculate ft at all values from 0:200 ..... The main task is to design a program to calculate the value of d(demand) at any required point
Maha Ahmed
2021 年 6 月 28 日
I get information from matlab help about conv and flip ... This not my case
Walter Roberson
2021 年 6 月 29 日
what should I do with (gui) ,i perform ft,rt with plot
I do not know what ft and rt are in this context?
and operate Handel function to calculate ft at all values from 0:200
I do not understand about "operate Handel function" ? If you mean "handle function" then I still do not understand?
The main task is to design a program to calculate the value of d(demand) at any required point
What is d in this context?
When you create your GUI, what inputs will the user have? What drop-down or listbox selection boxes will be provided to them, and what will they choose between? What pushbuttons will be provided, and what will those activate? What is the required output?
Maha Ahmed
2021 年 6 月 30 日
編集済み: Walter Roberson
2021 年 6 月 30 日
https://www.mathworks.com/matlabcentral/answers/uploaded_files/670273/IMG20210627123347.jpg> This is the sequence of my work, where ft is denisty function, RT is reliability function, i is acounter on time,l is a specific period of time,pl the production volume,d is demand which is the target of this mission to calculate it. The gui window is easy to design but the programming of it from editor is difficult to me. I perform a single scripts to calculate each step separately. How can I perform all the program inside the gui editor
Walter Roberson
2021 年 7 月 1 日
Have you taken the MATLAB Onramp course?
Are you familiar with the purpose of using functions, and how you can program functions in MATLAB?
Maha Ahmed
2021 年 7 月 1 日
No, i have very little experience about the basics of using MATLAB,i use it in small operations... This is the first project to me which i decided to perform all the work using MATLAB.. i face many difficulties so i decide to get a help from mathwork What should I do to organise my sequence of work and get the intended results quickly, i am constrained by limited time
Walter Roberson
2021 年 7 月 1 日
Generally speaking, organizing work into functions saves time, because you can debug the function separately.
A lot of the time when you are programming, you end up in situations where you have code that looks something like
first group of statements that produces some variables
second group of statements that uses the variables
where as far as the second group of statements is concerned, it does not matter how the first group of statements does its work, as long as particular variables are constructed correctly; and likewise that the first group of statements does not care how the second group of statements will use the variables.
In such a situation, it can often make sense to move the statements into functions,
[variable1, variable2, variable3] = first_function(input1, input2, input3);
[variable4, variable5] = second_function(variable1, variable2, variable3);
and then you
function [out1, out2, out3] = first_function(in1, in2, in3)
first group of statements
end
function [out4, out5] = second_function(in4, in5, in6)
second group of statements
end
Then you can change how first_function does its work without having to change how second_function does its work.
Breaking up code this way makes the original code more compact, allowing you to see more clearly what work it is intended to do. Also, breaking up the code like this reduces the number of accidental reliances between the first and the second group of code.
When code is broken up into functions with well-defined purposes, then often it turns out to be possible to re-use the function for other purposes, perhaps in other programs. Or it turns out that there are multiple places in the code where you did the same kind of logic (but perhaps with different variables), and then putting the logic into a function means you only have to debug the logic once, and the different places you had the logic do not get out of synchronization with each other (if you had written out code 5 times and notice a bug in one of the places and fix it, are you always going to remember to fix the other 4 places a well ?)
Maha Ahmed
2021 年 7 月 1 日
I will try to make one program with many section of functions to gather all my work steps... I hope to reach my target, thanks
Walter Roberson
2021 年 7 月 1 日
Your image of your equation leaves me with a number of questions.
- A: what is the subscript on the fand is that the same subscript as on the α at location C ?
- B: is that the same α as the one at location C ? It does not have any subscript or indexing, so maybe it refers to the whole vector α that is defined at location C? If so then f would have to return a vector value. And is the second α, the the same α ?
- C: what is the subscript on the α and is it the same as on the f at location A?
- D: That is the same subscript on the α at location C, right? So the vector is being defined iteratively. But to do that, you have to know -- unless what you are establishing is a series of simultaneous equations where each is being defined as the value that makes the entire system work out
- E: what is the upper bound on that summation? It looks like maybe the variable of summation is l (lower-case L), but for the upper bound I cannot read what it is equal to. Something minus 1. maybe? I cannot see any dot on whatever it is.
- F: what is the upper bound on the K summation? Is it i ?
- The bit at the bottom about for 0 ≤ something ≤ N -- what is the something? Is it t (lower-case T) ? Is it i (lower-case I) ? It looks most like a t but it would make more sense for it to be i
- The definition of f in location A: is that (M subscript lower-case F) ? Is that a named constant that is independent of the (M subscript lower-case R) in the definition of R(t) ? Or is that a vector M being indexed?
- The definition of R(t) looks to be using (a subscript r), and that a is not α (alpha). Then in the definition of f(t) at location A, there is an a subscript something. Is that subscript t? Is it 1 (digit 1) ?
- The definition of R(t) involes and σ with no subscript, and the definition of f(t) involves or maybe it is or maybe it is : what is the relationship between those σ?
- does not seem to be defined?
Maha Ahmed
2021 年 7 月 1 日
編集済み: Walter Roberson
2021 年 7 月 1 日
- A,C are the same subscript (j1 means part named j number 1)
- B,C are not the same indication B is a weight parameters in weibull part where C can replaced with any other variable, I want to calculate it at different i=1:200 and k=1:i known that the value of part c at i=0 is 1 ,and at i=1 is f(1)
- D and C have the same subscript, i want to get its value at any required i, known that its expansion is a function on f(t) where t have same meaning of i (counter on time series), i will upload an image to illustrate
- I will upload image to illustrate
- We have different mean, mean value related to R(t) and mean value related to f(t). so that subscript indication to the function
- In R(t) (a subscript r = .93) and in f(t) ( a subscript t= .986)... We can change these values in the program if we want
- In R(t) function sigma subscript r is the same as sigma without subscript= 30.7, In f(t) function sigma subscript f = 20.12 *P subscript r (L) is the production volume at L , where L is counter change over the time series from 1 to t-1 and t =0:200
Maha Ahmed
2021 年 7 月 1 日
編集済み: Walter Roberson
2021 年 7 月 1 日
<</matlabcentral/answers/uploaded_files/671628/IMG20210701200517.jpg
>>
Maha Ahmed
2021 年 7 月 1 日
It seams complicated task, but the programming of it with MATLAB is my challenge
Maha Ahmed
2021 年 7 月 8 日
I want to make a MATLAB gui to calculate d(i), i uploaded before all equations that require for this task. I failed in my iterations to create it alone. I need a help from mathworks to perform this operation.
Walter Roberson
2021 年 7 月 8 日
You did not post a copy of your code (only an image of part of it). You did not attach your fig file. You did not post an error message or ask any specific question.
Volunteers might assist you with your code, but we are not going to write your code for you.
Maha Ahmed
2021 年 7 月 10 日
function varargout = demand(varargin)
% DEMAND MATLAB code for demand.fig
% DEMAND, by itself, creates a new DEMAND or raises the existing
% singleton*.
%
% H = DEMAND returns the handle to a new DEMAND or the handle to
% the existing singleton*.
%
% DEMAND('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DEMAND.M with the given input arguments.
%
% DEMAND('Property','Value',...) creates a new DEMAND or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before demand_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to demand_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help demand
% Last Modified by GUIDE v2.5 05-Jul-2021 16:07:38
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @demand_OpeningFcn, ...
'gui_OutputFcn', @demand_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before demand is made visible.
function demand_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to demand (see VARARGIN)
% Choose default command line output for demand
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes demand wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = demand_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
function Ar_edit_Callback(hObject, eventdata, handles)
% hObject handle to Ar_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Ar_edit as text
% str2double(get(hObject,'String')) returns contents of Ar_edit as a double
% --- Executes during object creation, after setting all properties.
function Ar_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to Ar_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function sigmar_edit_Callback(hObject, eventdata, handles)
% hObject handle to sigmar_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of sigmar_edit as text
% str2double(get(hObject,'String')) returns contents of sigmar_edit as a double
% --- Executes during object creation, after setting all properties.
function sigmar_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to sigmar_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Mr_edit_Callback(hObject, eventdata, handles)
% hObject handle to Mr_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Mr_edit as text
% str2double(get(hObject,'String')) returns contents of Mr_edit as a double
% --- Executes during object creation, after setting all properties.
function Mr_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to Mr_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function alfa_edit_Callback(hObject, eventdata, handles)
% hObject handle to alfa_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of alfa_edit as text
% str2double(get(hObject,'String')) returns contents of alfa_edit as a double
% --- Executes during object creation, after setting all properties.
function alfa_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to alfa_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function bf_edit_Callback(hObject, eventdata, handles)
% hObject handle to bf_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of bf_edit as text
% str2double(get(hObject,'String')) returns contents of bf_edit as a double
% --- Executes during object creation, after setting all properties.
function bf_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to bf_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function kf_edit_Callback(hObject, eventdata, handles)
% hObject handle to kf_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of kf_edit as text
% str2double(get(hObject,'String')) returns contents of kf_edit as a double
% --- Executes during object creation, after setting all properties.
function kf_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to kf_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Af_edit_Callback(hObject, eventdata, handles)
% hObject handle to Af_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Af_edit as text
% str2double(get(hObject,'String')) returns contents of Af_edit as a double
% --- Executes during object creation, after setting all properties.
function Af_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to Af_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function sigmaf_edit_Callback(hObject, eventdata, handles)
% hObject handle to sigmaf_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of sigmaf_edit as text
% str2double(get(hObject,'String')) returns contents of sigmaf_edit as a double
% --- Executes during object creation, after setting all properties.
function sigmaf_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to sigmaf_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function Mf_edit_Callback(hObject, eventdata, handles)
% hObject handle to Mf_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of Mf_edit as text
% str2double(get(hObject,'String')) returns contents of Mf_edit as a double
% --- Executes during object creation, after setting all properties.
function Mf_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to Mf_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in popupmenu1.
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
% --- Executes during object creation, after setting all properties.
function popupmenu1_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in demand_push.
function demand_push_Callback(hObject, eventdata, handles)
% hObject handle to demand_push (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Alfa = str2double(get(handles.alfa_edit,'string'));
bf = str2double(get(handles.bf_edit,'string'));
kf = str2double(get(handles.kf_edit,'string'));
Af = str2double(get(handles.Af_edit,'string'));
sigmaf = str2double(get(handles.sigmaf_edit,'string' ));
Mf = str2double(get(handles.Mf_edit,'string'));
t=1:200;
f=@(t)(Alfa/bf)*kf*(t.^(kf-1)).*exp(-((t.^kf)/bf))+(1-Alfa)*(1/(Af*sigma-f*((2*pi)^0.5))).*exp(-(((t-Mf).^2)/(2*(sigmaf.^2))));
Ar = str2double(get(handles.Ar_edit,'string'));
sigmar = str2double(get(handles.sigmar_edit,'string'));
Mr = str2double(get(handles.Mr_edit,'string'));
t=1:200;
R=@(t)1-(1/(Ar*sigma-r*((2*pi)^0.5))).*exp(-(((t-Mr).^2)/(2*(sigmar.^2))));
for t=2:200
sum=0
for j=2:t
sum=sum+sum(t-j).*f(j)
end
v(t)=sum
end
val=get(handles.popupmenu1,'value');
str=get(handles.popupmenu1,'num');
switch str{val};
case 10000;
p=10000;
case 20000;
p=20000;
case 30000;
p=30000;
case 50000;
p=50000;
end
d(1)=0
for t=2:200
total=0
for l=1:t-1
total=total+v(t-l).*R(t-l).*p
end
d(t)=total
end
Demand =d(t)
m=dub2str(set(handles.demand_edit,'string',Demand))
function demand_edit_Callback(hObject, eventdata, handles)
% hObject handle to demand_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of demand_edit as text
% str2double(get(hObject,'String')) returns contents of demand_edit as a double
% --- Executes during object creation, after setting all properties.
function demand_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to demand_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
when i run this gui program, i get this error massage
what should i do
sum =
0
Array indices must be positive integers or logical values.
Error in demand>demand_push_Callback (line 332)
sum=sum+sum(t-j).*f(j)
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in demand (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)demand('demand_push_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
Walter Roberson
2021 年 7 月 11 日
for t=2:200
sum=0
for j=2:t
sum=sum+sum(t-j).*f(j)
end
v(t)=sum
end
t starts at 2. j starts at 2. t-j starts at 0. sum starts at the scalar 0. sum(t-j) would be sum(0) which is an invalid index.
The associated logic never stores more than 1 value in sum so sum can only be indexed at 1 (or true)
Reminder that matlab does not support implied multiplication. If you want multiplication then you need to use a multiplication operator.
採用された回答
Walter Roberson
2021 年 6 月 29 日
x = @(K) pi*exp(-(K-3).^2);
a = rand();
b = rand();
bounds = sort(rand(1,2))
bounds = 1×2
0.2767 0.5438
pd = makedist('Weibull','a',a,'b',b);
pdd = truncate(pd, bounds(1), bounds(2))
pdd =
WeibullDistribution
Weibull distribution
A = 0.500496
B = 0.36551
Truncated to the interval [0.276723, 0.543765]
f = @(k) cdf(pdd, k)
f = function_handle with value:
@(k)cdf(pdd,k)
for i = 1 : 200
itotal = 0;
for k = 1 : i
itotal = itotal + x(i-k)*f(k);
end
X(i) = itotal;
end
X
X = 1×200
0.0004 0.0579 1.2137 4.3552 5.5110 5.5685 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689 5.5689
7 件のコメント
Maha Ahmed
2021 年 7 月 1 日
編集済み: Walter Roberson
2021 年 7 月 1 日
What the point of the first seven lines in your code? I want to replace them with the direct function of f(t)
% All parameters
k=.3,b=27.5,al=.24,at=.906,mu=142.9,sig=20.12
f=@(t) (al/b)*k*(t.^(k-1).*exp(-((t.^k)/b)+(1-al)*(1/(at*sig*((2*pi)^.5))).*exp(-(((t-mu).^2/(2*(sig.^2)))
for i = 1 : 200
itotal = 0;
for k = 1 : i
itotal = itotal + x(i-k)*f(k);
end
X(i) = itotal;
end
X
end
Maha Ahmed
2021 年 7 月 1 日
I think there is wrong thing related to x .. the error massage tell this, if the code is right the value of alfa(1) at i=1 and k=1 should equal to the value of f(1) or at time t=t
Walter Roberson
2021 年 7 月 1 日
The point of the first lines of code is that in order to demonstrate a weibell distribution and demonstrate that the code can work, that I needed some parameters for the weibell distribution, as you had not provided any parameters.
In general, when I produce demonstrations for people, and I hardcode constants such as a=1/10 b = 2/3, then people start wondering why I used those constants, since they don't represent the situation the user happened to have, and start to suspect that my code would work for only those constants. When I code rand() instead of particular values, then the "message" is that the user can substitute whatever parameter values are meaningful for their situation and that the code will still work.
Walter Roberson
2021 年 7 月 1 日
Count your brackets. The digits on the line underneath are the number of open brackets "after" the character above is interpreted
f=@(t) (al/b)*k*(t.^(k-1).*exp(-((t.^k)/b)+(1-al)*(1/(at*sig*((2*pi)^.5))).*exp(-(((t-mu).^2/(2*(sig.^2)))
1 0 1 0 1 2 1 2 34 3 2 3 2 3 4 56 5 432 3 456 5 6 7 654
so you are missing four )
Maha Ahmed
2021 年 7 月 1 日
編集済み: Walter Roberson
2021 年 7 月 1 日
I think this is the edit to apply the same function in the image
f=@(t) (al/b)*k*(t.^(k-1)).*exp(-((t.^k)/b))+(1-al)*(1/(at*sig*(2*pi)^.5))).*exp(-(t-mu).^2/(2*(sig.^2)))
Walter Roberson
2021 年 7 月 1 日
f=@(t) (al/b)*k*(t.^(k-1)).*exp(-((t.^k)/b))+(1-al)*(1/(at*sig*(2*pi)^.5))).*exp(-(t-mu).^2/(2*(sig.^2)))
1 0 1 0 1 2 10 1 23 2 10 1 0 1 2 3 2 10! 0 1 0 1 2 10!
Here ! means the open-bracket count has gone to negative 1.
Maha Ahmed
2021 年 7 月 1 日
編集済み: Walter Roberson
2021 年 7 月 1 日
f=@(t) (al/b)*k*(t.^(k-1)).*exp(-((t.^k)/b))+(1-al)*(1/(at*sig*(2*pi)^.5)).*exp(-(t-mu).^2/(2*(sig.^2)))
その他の回答 (2 件)
Mahaveer Singh
2021 年 7 月 13 日
S=0;
x(1)=0; % initial value of x.
for i=2:1:200
for k=1:1:i-1
S(k)=x(i-k).*f(k);
end
x(i)=sum(S);
end
sumation=x
1 件のコメント
Sara Boznik
2021 年 6 月 27 日
part=0;
sumation=0;
for i=1:1:200
for k=1:1:i
part=x(i-k).*f(k)
sumation=sumation+part
end
end
Sumation is x(i).
4 件のコメント
Maha Ahmed
2021 年 6 月 27 日
This needs to define the function f before the loop to use it after that in loop
Maha Ahmed
2021 年 6 月 27 日
f(k) is weibull trankated normal distribution function ,all parameters are known, k is the only variable Alfa(i)=sumation of (alfa(i-k)*f(k)), these sumation from k=1tok=i, and i=1to 200
参考
カテゴリ
Help Center および File Exchange で Data Type Identification についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)