I have created a function (lets call it function A) in MATLAB that uses 'for loop' to create a 3*4 matrix. I am creating another MATLAB function (lets call it function B) that has absolutely no relation with function A but needs to use the matrix from function A.
How do I call only the matrix from function A to function B such that as this matrix changes in function A it triggers corresponding changes in function B as well?
Is there a way I can save the matrix in function A after the 'for loop' such that I can call the matrix anywhere else I choose?
Thanks
Lets take an example that You have created a matrix 'Y' in function A. You can take it as return
syntax
function [Y] = Function_A()
%% function body%%
end
then on main window you can write
C=Function_A();
so the matrix on which you have performed operation will be returned by Function_A and will get store in C;
now you can pass this matrix in Function_B by writing
Function_B(C);
for full example i am creating two function with same name as given in the problem
| function[Y]= Function_A() Y=eye(4); end |
above created a function with name Function_A which create a matrix Y which is 4*4 identity matrix;
and below is the function with name Function_B which will then calculate the determinent of that matrix and store it in 'r' and then return it. below a picture attached see how to use it
| function[r]= Function_B(C) r=det(C); end |

Hope u understood it
Please dont forget to like❤️
I have created a function (lets call it function A) in MATLAB that uses 'for loop'...
In matlab I have created the following function function [distance, xplot, yplot] = Cannon_lab8(V, theta) % the function calculates the distance a projectile travels when shot from % a cannon given initial velocity and theta. g = -9.81; % m/s^2 k = 0.35; % drag coefficient Vx = V*cos(theta); Vy = V*sin(theta); dt = 0.01; % seconds x = 0; y = 0; xplot(1) = 0; yplot(1) = 0; i = 2; while y >= 0 ax = -k*Vx; ay...
using this array
I need to create a user created function in Matlab
that does the following
I have this so far but I'm so lost
could you please make this with comments on what the
codes do
Lure dueren suuj (COM 94 97 95 19 91 88 95 87 90 72 78 60 98 87 81 79 76 69 192 80 77 73 78 70 80 89 81 186 94 901 b. Find the lowest grade in Math subject...
In matlab I have created the following function that calculates the distance a projectile travels when shot from a cannon given initial velocity and theta. function [distance, xplot, yplot] = Cannon_lab8(V, theta) g = -9.81; % gravity m/s^2 k = 0.35; % drag coefficient Vx = V*cos(theta); %velovity in x-direction Vy = V*sin(theta); %velovity in y-direction dt = 0.01; % seconds, time step x = 0; y = 0; xplot(1) = 0; yplot(1) = 0; i = 2; while y...
I have a simple C++ RPC that lets you have remote class instances that support live members (data structures) update as well as method calls. For example I had a class declared like this (pseudocode): class Sum{ public: RPC_FIELD(int lastSum); RPC_METHOD(int summ(int a, int b)) { lastSum = a + b; return lastSum; } }; On machine A I had its instance. On machines B and C I had created its instances and connected...
MATLAB QUESTION. function [output1,output2] = myFunction(a,b) output1 = a*5; output2 = output1*10; end Then I have a script with values for a and b. How can I call the previous function so that i get output2? a=10; b=10; (How can I get output 2?) it has to run as a script
Problem 1 (10 pts) (Matlab coding) In this problem you will be manipulating a sine wave plot using a for loop and if statements. a) Create a vector x that goes from −4π to 4π with increments of π/10. b) Instead of using y = sin(x) on the entire array at once, use a for loop to calculate the sine of x for each value in the vector individually. Vector y should be the sine of vector x. Use the...
For this project, each part will be in its oun matlab script. You will be uploading a total 3 m files. Be sure to make your variable names descriptive, and add comments regularly to describe what your code is doing and hou your code aligns with the assignment 1 Iterative Methods: Conjugate Gradient In most software applications, row reduction is rarely used to solve a linear system Ar-b instead, an iterative algorithm like the one presented below is used. 1.1...
A code in matlab. (maybe Jammer can answer)?
Consider the following income tax brackets. Income ($) 0 - 10,000 10,000 - 25,000 Tax 0% 5% on amount exceeding 10,000 $750 + 8% on amount exceeding 25,000 $2,750 + 10% on amount exceeding 50,000 $7,750 + 15% on amount exceeding 100,000 $67,750 + 25% on amount exceeding 500,000 25,000 - 50.000 50,000-100,000 100,000-500,000 > 500,000 250 Thus, if the income is $70,000, then the fourth bracket will apply and the tax...
Help with SIMULINK of Matlab:
I want to put the transfer function, I have already located
function # 1, but how do I put function 2, so that it comes out as
well as the original function, what should I put in the numerator
and denominator? ..
Block Parameters: Transfer Fcn5 Х Transfer Fon Function1: K*wn^2 S2+2*zhita*wns The numerator coefficient can be a vector or matrix expression. The denominator coefficient must be a vector. The output width equals the number...
I am creating a recursive function in c++ and have the following code so far. However, can you help me fix it so that it doesn't crash when negative numbers are entered. If negative numbers are entered i want to let the user know negative numbers are not accepted and to try again #include <iostream> using namespace std; int multiplication(int x, int y) { int sum = y; //if value of x is 1, then result of x*y will be...