How to perform arithmetic calculation for matrix stored in a structure array??

Hi all, I have previously written a code to do curvefitting and have several variables(eg.estimateONE and estimateTWO) in matrix form. So I used dlmwrite as shown below to save these matices,thinking that I do not have to go through the hassle of running the curvefitting code again and able to perform arithmetic calculation on them in the future.
%%Example of code to save the estimateONE matrix as estimateONE.txt
% dlmwrite('estimateONE.txt', estimateONE, 'delimiter', '\t','precision', 4)
% type estimateONE.txt
%%Code to read the estimateONE file
filename = 'estimateONE.txt';
delimiterIn = '\t';
headerlinesIn = 1;
estimateONE = importdata(filename,delimiterIn,headerlinesIn);
However, when I used this code to access the matrix, I have a structure estimateONE and the data are stored as estimateONE.data
So how can I retrieve the estimateONE.data and then perform arithmetic calculation such as dividing it with another data matrix such as estimateTWO.data stored in another structure array called estimateTWO?? Because it is no longer an array which can be read using the fscanf function.
Really really appreciate any form of help extended.
Best regards

 Réponse acceptée

estimateONE.data ./ estimateTWO.data

3 commentaires

Shing
Shing le 10 Mar 2013
Modifié(e) : Shing le 10 Mar 2013
Hi sir, actually I am abit confused on structure.
Do I use a different method to access estimateONE.data matrix which is (260 by 260) stored in a structure as compared to a matrix which is not stored in structure? Because like for non-structured matrix, I can compute the non-zeros elements by defining boundaries like :
for row=1:1:256
for col=1:1:256
if estimateONE(i,j)==0 count=count+1; end end end
Can I do the same for matrix stored inside structure like estimateONE.data?
Thank you for your help ! :)
Hello Shing,
if I have clearly understood your problem, then my answer would be that using an array stored in "estimateONE" or another one stored in "estimateONE.data" is the same, as long as the evaluation of both variable in the corresponding cases returns the same values and types! For example the following lines will print the same values on the command line twice!
estimateONE = [ 1 2;3 4];
estimateONE = estimateONE.^2;
estimateONE
clear all
estimateONE.data = [ 1 2;3 4];
estimateONE.data = estimateONE.data .^2;
estimateONE.data
yes I understand now, thank you so much for your help ! :))

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by