Multiple variable inputs for a function
이전 댓글 표시
for i=1:1:6
for q=1:1:50
x=P(i,3)
y=P(i,2)
a=0
b=[x1,y1,z1]
P=xlsread('file');
f(1)=e(q,1);
f(2)=e(q,2);
f(3)=e(q,3);
end
[function of x,y,a,b,P,f]=...
w= stored outputs from the function above
end
I am having an issue with being able to vary 'i' and thus the inputs that correspond with 'i' whilst also changing the inputs corresponding to 'q' for each respective 'i.' ie if i represents the months january to june and f represents multiple locations. I would like to find the outputs of the function at every location for each month and thus for each x and y. Hopefully that makes sense any advice would be appreciated as I am not too familiar with for loops or/ if they are even needed here. 'from the function above' shouldnt be purple but i cant change it
I need to know how when i=1 and q=1,2,3,4...50. what the function would be equal to at each location vector,f and then do the same for i=2 q=1,2,3,4...50 and so on. More the process behind how than the specifics..
댓글 수: 5
Jan
2021년 4월 10일
There is no variable called 'z' in your code.
You access P before importing it.
This is no valid Matlab code, so we cannot guess, what it should do:
[function of x,y,a,b,P,f]=...
w=Stored values of outputs of functions
The meaning of the shown code is not clear. Please edit the question and add more details. Start with some running code, even if it does not do all you want.
Rik
2021년 4월 11일
Why did you delete your question? That is extremely rude.
john smith
2021년 4월 11일
편집: john smith
2021년 4월 11일
Rik
2021년 4월 11일
It is indeed an open forum, but that doesn't mean you can do anything you like without consequences.
You can delete your question until somebody posts an answer. After that, somebody has taken the time to understand your question, find a solution, and post an explanation. By that point it is insulting to delete the question. That is why the button was gone.
If you want private consultation, you shouldn't post on a public forum.
Rena Berman
2021년 5월 6일
(Answers Dev) Restored edit
답변 (1개)
Ayham Aljawabrah
2021년 4월 10일
편집: Ayham Aljawabrah
2021년 4월 10일
The logical order of the code is not correct and the function definition as well. A guide code can help you to reconstruct your code
a=0
u= @(x,y,a,b,f) -Enter_your_function_here-
P=xlsread('file');
for i=1:6
x=P(i,3)
y=P(i,2)
for q=1:50
b=[x1,y1,z1] % x1,y1,z1 are not apperent in the code, make sure to declare them
f(1)=e(q,1);
f(2)=e(q,2);
f(3)=e(q,3);% e is not apperent in the code, make sure to declare it
w=u(x,y,a,b,f) % this line depends on the function u output structure
end
end
카테고리
도움말 센터 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!